@zigc/lib 0.16.0-dev.3132 → 0.16.0-dev.3142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.16.0-dev.3132",
3
+ "version": "0.16.0-dev.3142",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -420,12 +420,21 @@ fn render_cmake(
420
420
  };
421
421
  defer allocator.free(line);
422
422
 
423
- if (!std.mem.startsWith(u8, line, "#")) {
423
+ const line_start = std.mem.findNone(u8, line, " \t\r") orelse {
424
+ try bw.writeAll(line);
425
+ if (!last_line) try bw.writeByte('\n');
426
+ continue;
427
+ };
428
+ const whitespace_prefix = line[0..line_start];
429
+ const trimmed_line = line[line_start..];
430
+
431
+ if (!std.mem.startsWith(u8, trimmed_line, "#")) {
424
432
  try bw.writeAll(line);
425
433
  if (!last_line) try bw.writeByte('\n');
426
434
  continue;
427
435
  }
428
- var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
436
+
437
+ var it = std.mem.tokenizeAny(u8, trimmed_line[1..], " \t\r");
429
438
  const cmakedefine = it.next().?;
430
439
  if (!std.mem.eql(u8, cmakedefine, "cmakedefine") and
431
440
  !std.mem.eql(u8, cmakedefine, "cmakedefine01"))
@@ -502,6 +511,7 @@ fn render_cmake(
502
511
  value = Value{ .ident = it.rest() };
503
512
  }
504
513
 
514
+ try bw.writeAll(whitespace_prefix);
505
515
  try renderValueC(bw, name, value);
506
516
  }
507
517
 
@@ -6090,12 +6090,19 @@ fn dirRealPathFileWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8,
6090
6090
  }
6091
6091
  };
6092
6092
  defer windows.CloseHandle(h_file);
6093
- return realPathWindows(h_file, out_buffer);
6093
+
6094
+ // We can re-use the path buffer for the WTF-16 representation since
6095
+ // we don't need the prefixed path anymore
6096
+ return realPathWindowsBuf(h_file, out_buffer, &path_name_w.data);
6094
6097
  }
6095
6098
 
6096
6099
  fn realPathWindows(h_file: windows.HANDLE, out_buffer: []u8) File.RealPathError!usize {
6097
6100
  var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined;
6098
- const wide_slice = try GetFinalPathNameByHandle(h_file, .{}, &wide_buf);
6101
+ return realPathWindowsBuf(h_file, out_buffer, &wide_buf);
6102
+ }
6103
+
6104
+ fn realPathWindowsBuf(h_file: windows.HANDLE, out_buffer: []u8, wtf16_buffer: []u16) File.RealPathError!usize {
6105
+ const wide_slice = try GetFinalPathNameByHandle(h_file, .{}, wtf16_buffer);
6099
6106
 
6100
6107
  const len = std.unicode.calcWtf8Len(wide_slice);
6101
6108
  if (len > out_buffer.len)
@@ -13010,6 +13017,7 @@ fn netReceiveOneWindows(
13010
13017
  .CANCELLED => unreachable,
13011
13018
  .INSUFFICIENT_RESOURCES => return error.SystemResources,
13012
13019
  .BUFFER_OVERFLOW => return error.MessageOversize,
13020
+ .PORT_UNREACHABLE => return error.PortUnreachable,
13013
13021
  else => |status| return windows.unexpectedStatus(status),
13014
13022
  }
13015
13023
  }
package/std/Io.zig CHANGED
@@ -374,6 +374,13 @@ pub const Operation = union(enum) {
374
374
  ConnectionResetByPeer,
375
375
  /// The local network interface used to reach the destination is offline.
376
376
  NetworkDown,
377
+ /// A connectionless packet was previously sent successfully,
378
+ /// however, it was not received because no service is operating at
379
+ /// the destination port of the transport on the remote system.
380
+ /// This caused an ICMP port unreachable packet to be returned to
381
+ /// the OS where it was queued up to be reported at the next call
382
+ /// to send or receive on the bound socket.
383
+ PortUnreachable,
377
384
  } || Io.UnexpectedError;
378
385
 
379
386
  pub const Result = struct { ?net.Socket.ReceiveError, usize };
@@ -2491,3 +2498,964 @@ test {
2491
2498
  _ = Semaphore;
2492
2499
  _ = @import("Io/test.zig");
2493
2500
  }
2501
+
2502
+ /// An implementation of `Io` which simulates a system supporting no `Io` operations.
2503
+ ///
2504
+ /// This system has the following properties:
2505
+ /// * Concurrency is unavailable.
2506
+ /// * The stdio handles are pipes whose remote ends are already closed.
2507
+ /// * The filesystem is entirely empty, including that the cwd is no longer present.
2508
+ /// * The filesystem is full, so attempting to create entries always returns `error.NoSpaceLeft`.
2509
+ /// * No entropy source is supported, so `randomSecure` always returns `error.EntropyUnavailable`, and `random` always returns (fills the buffer) with 0.
2510
+ /// * No clocks are supported, so `now` and `sleep` always return `error.UnsupportedClock`.
2511
+ /// * No network is connected, so network operations always return `error.NetworkDown`.
2512
+ pub const failing: std.Io = .{
2513
+ .userdata = null,
2514
+ .vtable = &.{
2515
+ .crashHandler = noCrashHandler,
2516
+
2517
+ .async = noAsync,
2518
+ .concurrent = failingConcurrent,
2519
+ .await = unreachableAwait,
2520
+ .cancel = unreachableCancel,
2521
+
2522
+ .groupAsync = noGroupAsync,
2523
+ .groupConcurrent = failingGroupConcurrent,
2524
+ .groupAwait = unreachableGroupAwait,
2525
+ .groupCancel = unreachableGroupCancel,
2526
+
2527
+ .recancel = unreachableRecancel,
2528
+ .swapCancelProtection = unreachableSwapCancelProtection,
2529
+ .checkCancel = unreachableCheckCancel,
2530
+
2531
+ .futexWait = noFutexWait,
2532
+ .futexWaitUncancelable = noFutexWaitUncancelable,
2533
+ .futexWake = noFutexWake,
2534
+
2535
+ .operate = failingOperate,
2536
+ .batchAwaitAsync = unreachableBatchAwaitAsync,
2537
+ .batchAwaitConcurrent = unreachableBatchAwaitConcurrent,
2538
+ .batchCancel = unreachableBatchCancel,
2539
+
2540
+ .dirCreateDir = failingDirCreateDir,
2541
+ .dirCreateDirPath = failingDirCreateDirPath,
2542
+ .dirCreateDirPathOpen = failingDirCreateDirPathOpen,
2543
+ .dirOpenDir = failingDirOpenDir,
2544
+ .dirStat = failingDirStat,
2545
+ .dirStatFile = failingDirStatFile,
2546
+ .dirAccess = failingDirAccess,
2547
+ .dirCreateFile = failingDirCreateFile,
2548
+ .dirCreateFileAtomic = failingDirCreateFileAtomic,
2549
+ .dirOpenFile = failingDirOpenFile,
2550
+ .dirClose = unreachableDirClose,
2551
+ .dirRead = noDirRead,
2552
+ .dirRealPath = failingDirRealPath,
2553
+ .dirRealPathFile = failingDirRealPathFile,
2554
+ .dirDeleteFile = failingDirDeleteFile,
2555
+ .dirDeleteDir = failingDirDeleteDir,
2556
+ .dirRename = failingDirRename,
2557
+ .dirRenamePreserve = failingDirRenamePreserve,
2558
+ .dirSymLink = failingDirSymLink,
2559
+ .dirReadLink = failingDirReadLink,
2560
+ .dirSetOwner = failingDirSetOwner,
2561
+ .dirSetFileOwner = failingDirSetFileOwner,
2562
+ .dirSetPermissions = failingDirSetPermissions,
2563
+ .dirSetFilePermissions = failingDirSetFilePermissions,
2564
+ .dirSetTimestamps = noDirSetTimestamps,
2565
+ .dirHardLink = failingDirHardLink,
2566
+
2567
+ .fileStat = failingFileStat,
2568
+ .fileLength = failingFileLength,
2569
+ .fileClose = unreachableFileClose,
2570
+ .fileWritePositional = failingFileWritePositional,
2571
+ .fileWriteFileStreaming = noFileWriteFileStreaming,
2572
+ .fileWriteFilePositional = noFileWriteFilePositional,
2573
+ .fileReadPositional = failingFileReadPositional,
2574
+ .fileSeekBy = failingFileSeekBy,
2575
+ .fileSeekTo = failingFileSeekTo,
2576
+ .fileSync = failingFileSync,
2577
+ .fileIsTty = unreachableFileIsTty,
2578
+ .fileEnableAnsiEscapeCodes = unreachableFileEnableAnsiEscapeCodes,
2579
+ .fileSupportsAnsiEscapeCodes = unreachableFileSupportsAnsiEscapeCodes,
2580
+ .fileSetLength = failingFileSetLength,
2581
+ .fileSetOwner = failingFileSetOwner,
2582
+ .fileSetPermissions = failingFileSetPermissions,
2583
+ .fileSetTimestamps = noFileSetTimestamps,
2584
+ .fileLock = failingFileLock,
2585
+ .fileTryLock = failingFileTryLock,
2586
+ .fileUnlock = unreachableFileUnlock,
2587
+ .fileDowngradeLock = failingFileDowngradeLock,
2588
+ .fileRealPath = failingFileRealPath,
2589
+ .fileHardLink = failingFileHardLink,
2590
+
2591
+ .fileMemoryMapCreate = failingFileMemoryMapCreate,
2592
+ .fileMemoryMapDestroy = unreachableFileMemoryMapDestroy,
2593
+ .fileMemoryMapSetLength = unreachableFileMemoryMapSetLength,
2594
+ .fileMemoryMapRead = unreachableFileMemoryMapRead,
2595
+ .fileMemoryMapWrite = unreachableFileMemoryMapWrite,
2596
+
2597
+ .processExecutableOpen = failingProcessExecutableOpen,
2598
+ .processExecutablePath = failingProcessExecutablePath,
2599
+ .lockStderr = unreachableLockStderr,
2600
+ .tryLockStderr = noTryLockStderr,
2601
+ .unlockStderr = unreachableUnlockStderr,
2602
+ .processCurrentPath = failingProcessCurrentPath,
2603
+ .processSetCurrentDir = failingProcessSetCurrentDir,
2604
+ .processSetCurrentPath = failingProcessSetCurrentPath,
2605
+ .processReplace = failingProcessReplace,
2606
+ .processReplacePath = failingProcessReplacePath,
2607
+ .processSpawn = failingProcessSpawn,
2608
+ .processSpawnPath = failingProcessSpawnPath,
2609
+ .childWait = unreachableChildWait,
2610
+ .childKill = unreachableChildKill,
2611
+
2612
+ .progressParentFile = failingProgressParentFile,
2613
+
2614
+ .random = noRandom,
2615
+ .randomSecure = failingRandomSecure,
2616
+
2617
+ .now = noNow,
2618
+ .clockResolution = failingClockResolution,
2619
+ .sleep = noSleep,
2620
+
2621
+ .netListenIp = failingNetListenIp,
2622
+ .netAccept = failingNetAccept,
2623
+ .netBindIp = failingNetBindIp,
2624
+ .netConnectIp = failingNetConnectIp,
2625
+ .netListenUnix = failingNetListenUnix,
2626
+ .netConnectUnix = failingNetConnectUnix,
2627
+ .netSocketCreatePair = failingNetSocketCreatePair,
2628
+ .netSend = failingNetSend,
2629
+ .netRead = failingNetRead,
2630
+ .netWrite = failingNetWrite,
2631
+ .netWriteFile = failingNetWriteFile,
2632
+ .netClose = unreachableNetClose,
2633
+ .netShutdown = failingNetShutdown,
2634
+ .netInterfaceNameResolve = failingNetInterfaceNameResolve,
2635
+ .netInterfaceName = unreachableNetInterfaceName,
2636
+ .netLookup = failingNetLookup,
2637
+ },
2638
+ };
2639
+
2640
+ pub fn noCrashHandler(userdata: ?*anyopaque) void {
2641
+ _ = userdata;
2642
+ }
2643
+
2644
+ pub fn noAsync(userdata: ?*anyopaque, result: []u8, result_alignment: std.mem.Alignment, context: []const u8, context_alignment: std.mem.Alignment, start: *const fn (context: *const anyopaque, result: *anyopaque) void) ?*AnyFuture {
2645
+ _ = userdata;
2646
+ _ = result_alignment;
2647
+ _ = context_alignment;
2648
+ start(context.ptr, result.ptr);
2649
+ return null;
2650
+ }
2651
+
2652
+ pub fn failingConcurrent(
2653
+ userdata: ?*anyopaque,
2654
+ result_len: usize,
2655
+ result_alignment: std.mem.Alignment,
2656
+ context: []const u8,
2657
+ context_alignment: std.mem.Alignment,
2658
+ start: *const fn (context: *const anyopaque, result: *anyopaque) void,
2659
+ ) ConcurrentError!*AnyFuture {
2660
+ _ = userdata;
2661
+ _ = result_len;
2662
+ _ = result_alignment;
2663
+ _ = context;
2664
+ _ = context_alignment;
2665
+ _ = start;
2666
+ return error.ConcurrencyUnavailable;
2667
+ }
2668
+
2669
+ pub fn unreachableAwait(
2670
+ userdata: ?*anyopaque,
2671
+ any_future: *AnyFuture,
2672
+ result: []u8,
2673
+ result_alignment: std.mem.Alignment,
2674
+ ) void {
2675
+ _ = userdata;
2676
+ _ = any_future;
2677
+ _ = result;
2678
+ _ = result_alignment;
2679
+ unreachable;
2680
+ }
2681
+
2682
+ pub fn unreachableCancel(
2683
+ userdata: ?*anyopaque,
2684
+ any_future: *AnyFuture,
2685
+ result: []u8,
2686
+ result_alignment: std.mem.Alignment,
2687
+ ) void {
2688
+ _ = userdata;
2689
+ _ = any_future;
2690
+ _ = result;
2691
+ _ = result_alignment;
2692
+ unreachable;
2693
+ }
2694
+
2695
+ pub fn noGroupAsync(
2696
+ userdata: ?*anyopaque,
2697
+ group: *Group,
2698
+ context: []const u8,
2699
+ context_alignment: std.mem.Alignment,
2700
+ start: *const fn (context: *const anyopaque) void,
2701
+ ) void {
2702
+ _ = userdata;
2703
+ _ = group;
2704
+ _ = context_alignment;
2705
+ start(context.ptr);
2706
+ }
2707
+
2708
+ pub fn failingGroupConcurrent(
2709
+ userdata: ?*anyopaque,
2710
+ group: *Group,
2711
+ context: []const u8,
2712
+ context_alignment: std.mem.Alignment,
2713
+ start: *const fn (context: *const anyopaque) void,
2714
+ ) ConcurrentError!void {
2715
+ _ = userdata;
2716
+ _ = group;
2717
+ _ = context;
2718
+ _ = context_alignment;
2719
+ _ = start;
2720
+ return error.ConcurrencyUnavailable;
2721
+ }
2722
+
2723
+ pub fn unreachableGroupAwait(userdata: ?*anyopaque, group: *Group, token: *anyopaque) Cancelable!void {
2724
+ _ = userdata;
2725
+ _ = group;
2726
+ _ = token;
2727
+ unreachable;
2728
+ }
2729
+
2730
+ pub fn unreachableGroupCancel(userdata: ?*anyopaque, group: *Group, token: *anyopaque) void {
2731
+ _ = userdata;
2732
+ _ = group;
2733
+ _ = token;
2734
+ unreachable;
2735
+ }
2736
+
2737
+ pub fn unreachableRecancel(userdata: ?*anyopaque) void {
2738
+ _ = userdata;
2739
+ unreachable;
2740
+ }
2741
+
2742
+ pub fn unreachableSwapCancelProtection(userdata: ?*anyopaque, new: CancelProtection) CancelProtection {
2743
+ _ = userdata;
2744
+ _ = new;
2745
+ unreachable;
2746
+ }
2747
+
2748
+ pub fn unreachableCheckCancel(userdata: ?*anyopaque) Cancelable!void {
2749
+ _ = userdata;
2750
+ unreachable;
2751
+ }
2752
+
2753
+ pub fn noFutexWait(userdata: ?*anyopaque, ptr: *const u32, expected: u32, timeout: Timeout) Cancelable!void {
2754
+ _ = userdata;
2755
+ std.debug.assert(ptr.* == expected or timeout != .none);
2756
+ }
2757
+
2758
+ pub fn noFutexWaitUncancelable(userdata: ?*anyopaque, ptr: *const u32, expected: u32) void {
2759
+ _ = userdata;
2760
+ std.debug.assert(ptr.* == expected);
2761
+ }
2762
+
2763
+ pub fn noFutexWake(userdata: ?*anyopaque, ptr: *const u32, max_waiters: u32) void {
2764
+ _ = userdata;
2765
+ _ = ptr;
2766
+ _ = max_waiters;
2767
+ // no-op
2768
+ }
2769
+
2770
+ pub fn failingOperate(userdata: ?*anyopaque, operation: Operation) Cancelable!Operation.Result {
2771
+ _ = userdata;
2772
+ return switch (operation) {
2773
+ .file_read_streaming => .{ .file_read_streaming = error.InputOutput },
2774
+ .file_write_streaming => .{ .file_write_streaming = error.InputOutput },
2775
+ .device_io_control => unreachable,
2776
+ .net_receive => .{ .net_receive = .{ error.NetworkDown, 0 } },
2777
+ };
2778
+ }
2779
+
2780
+ pub fn unreachableBatchAwaitAsync(userdata: ?*anyopaque, b: *Batch) Cancelable!void {
2781
+ _ = userdata;
2782
+ _ = b;
2783
+ unreachable;
2784
+ }
2785
+
2786
+ pub fn unreachableBatchAwaitConcurrent(userdata: ?*anyopaque, b: *Batch, timeout: Timeout) Batch.AwaitConcurrentError!void {
2787
+ _ = userdata;
2788
+ _ = b;
2789
+ _ = timeout;
2790
+ unreachable;
2791
+ }
2792
+
2793
+ pub fn unreachableBatchCancel(userdata: ?*anyopaque, b: *Batch) void {
2794
+ _ = userdata;
2795
+ _ = b;
2796
+ unreachable;
2797
+ }
2798
+
2799
+ pub fn failingDirCreateDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirError!void {
2800
+ _ = userdata;
2801
+ _ = dir;
2802
+ _ = sub_path;
2803
+ _ = permissions;
2804
+ return error.NoSpaceLeft;
2805
+ }
2806
+
2807
+ pub fn failingDirCreateDirPath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirPathError!Dir.CreatePathStatus {
2808
+ _ = userdata;
2809
+ _ = dir;
2810
+ _ = sub_path;
2811
+ _ = permissions;
2812
+ return error.NoSpaceLeft;
2813
+ }
2814
+
2815
+ pub fn failingDirCreateDirPathOpen(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions, options: Dir.OpenOptions) Dir.CreateDirPathOpenError!Dir {
2816
+ _ = userdata;
2817
+ _ = dir;
2818
+ _ = sub_path;
2819
+ _ = permissions;
2820
+ _ = options;
2821
+ return error.NoSpaceLeft;
2822
+ }
2823
+
2824
+ pub fn failingDirOpenDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.OpenOptions) Dir.OpenError!Dir {
2825
+ _ = userdata;
2826
+ _ = dir;
2827
+ _ = sub_path;
2828
+ _ = options;
2829
+ return error.FileNotFound;
2830
+ }
2831
+
2832
+ pub fn failingDirStat(userdata: ?*anyopaque, dir: Dir) Dir.StatError!Dir.Stat {
2833
+ _ = userdata;
2834
+ _ = dir;
2835
+ return error.Streaming;
2836
+ }
2837
+
2838
+ pub fn failingDirStatFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.StatFileOptions) Dir.StatFileError!File.Stat {
2839
+ _ = userdata;
2840
+ _ = dir;
2841
+ _ = sub_path;
2842
+ _ = options;
2843
+ return error.FileNotFound;
2844
+ }
2845
+
2846
+ pub fn failingDirAccess(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.AccessOptions) Dir.AccessError!void {
2847
+ _ = userdata;
2848
+ _ = dir;
2849
+ _ = sub_path;
2850
+ _ = options;
2851
+ return error.FileNotFound;
2852
+ }
2853
+
2854
+ pub fn failingDirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: File.CreateFlags) File.OpenError!File {
2855
+ _ = userdata;
2856
+ _ = dir;
2857
+ _ = sub_path;
2858
+ _ = options;
2859
+ return error.NoSpaceLeft;
2860
+ }
2861
+
2862
+ pub fn failingDirCreateFileAtomic(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.CreateFileAtomicOptions) Dir.CreateFileAtomicError!File.Atomic {
2863
+ _ = userdata;
2864
+ _ = dir;
2865
+ _ = sub_path;
2866
+ _ = options;
2867
+ return error.NoSpaceLeft;
2868
+ }
2869
+
2870
+ pub fn failingDirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File {
2871
+ _ = userdata;
2872
+ _ = dir;
2873
+ _ = sub_path;
2874
+ _ = flags;
2875
+ return error.FileNotFound;
2876
+ }
2877
+
2878
+ pub fn unreachableDirClose(userdata: ?*anyopaque, dirs: []const Dir) void {
2879
+ _ = userdata;
2880
+ _ = dirs;
2881
+ unreachable;
2882
+ }
2883
+
2884
+ pub fn noDirRead(userdata: ?*anyopaque, dir_reader: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
2885
+ _ = userdata;
2886
+ _ = dir_reader;
2887
+ _ = buffer;
2888
+ return 0;
2889
+ }
2890
+
2891
+ pub fn failingDirRealPath(userdata: ?*anyopaque, dir: Dir, out_buffer: []u8) Dir.RealPathError!usize {
2892
+ _ = userdata;
2893
+ _ = dir;
2894
+ _ = out_buffer;
2895
+ return error.FileNotFound;
2896
+ }
2897
+
2898
+ pub fn failingDirRealPathFile(userdata: ?*anyopaque, dir: Dir, path_name: []const u8, out_buffer: []u8) Dir.RealPathFileError!usize {
2899
+ _ = userdata;
2900
+ _ = dir;
2901
+ _ = path_name;
2902
+ _ = out_buffer;
2903
+ return error.FileNotFound;
2904
+ }
2905
+
2906
+ pub fn failingDirDeleteFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void {
2907
+ _ = userdata;
2908
+ _ = dir;
2909
+ _ = sub_path;
2910
+ return error.FileNotFound;
2911
+ }
2912
+
2913
+ pub fn failingDirDeleteDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void {
2914
+ _ = userdata;
2915
+ _ = dir;
2916
+ _ = sub_path;
2917
+ return error.FileNotFound;
2918
+ }
2919
+
2920
+ pub fn failingDirRename(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8) Dir.RenameError!void {
2921
+ _ = userdata;
2922
+ _ = old_dir;
2923
+ _ = old_sub_path;
2924
+ _ = new_dir;
2925
+ _ = new_sub_path;
2926
+ return error.FileNotFound;
2927
+ }
2928
+
2929
+ pub fn failingDirRenamePreserve(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8) Dir.RenamePreserveError!void {
2930
+ _ = userdata;
2931
+ _ = old_dir;
2932
+ _ = old_sub_path;
2933
+ _ = new_dir;
2934
+ _ = new_sub_path;
2935
+ return error.FileNotFound;
2936
+ }
2937
+
2938
+ pub fn failingDirSymLink(userdata: ?*anyopaque, dir: Dir, target_path: []const u8, sym_link_path: []const u8, flags: Dir.SymLinkFlags) Dir.SymLinkError!void {
2939
+ _ = userdata;
2940
+ _ = dir;
2941
+ _ = target_path;
2942
+ _ = sym_link_path;
2943
+ _ = flags;
2944
+ return error.FileNotFound;
2945
+ }
2946
+
2947
+ pub fn failingDirReadLink(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize {
2948
+ _ = userdata;
2949
+ _ = dir;
2950
+ _ = sub_path;
2951
+ _ = buffer;
2952
+ return error.FileNotFound;
2953
+ }
2954
+
2955
+ pub fn failingDirSetOwner(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void {
2956
+ _ = userdata;
2957
+ _ = dir;
2958
+ _ = owner;
2959
+ _ = group;
2960
+ return error.FileNotFound;
2961
+ }
2962
+
2963
+ pub fn failingDirSetFileOwner(userdata: ?*anyopaque, dir: std.Io.Dir, sub_path: []const u8, owner: ?File.Uid, group: ?File.Gid, options: Dir.SetFileOwnerOptions) Dir.SetFileOwnerError!void {
2964
+ _ = userdata;
2965
+ _ = dir;
2966
+ _ = sub_path;
2967
+ _ = owner;
2968
+ _ = group;
2969
+ _ = options;
2970
+ return error.FileNotFound;
2971
+ }
2972
+
2973
+ pub fn failingDirSetPermissions(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void {
2974
+ _ = userdata;
2975
+ _ = dir;
2976
+ _ = permissions;
2977
+ return error.FileNotFound;
2978
+ }
2979
+
2980
+ pub fn failingDirSetFilePermissions(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: File.Permissions, options: Dir.SetFilePermissionsOptions) Dir.SetFilePermissionsError!void {
2981
+ _ = userdata;
2982
+ _ = dir;
2983
+ _ = sub_path;
2984
+ _ = permissions;
2985
+ _ = options;
2986
+ return error.FileNotFound;
2987
+ }
2988
+
2989
+ pub fn noDirSetTimestamps(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.SetTimestampsOptions) Dir.SetTimestampsError!void {
2990
+ _ = userdata;
2991
+ _ = dir;
2992
+ _ = sub_path;
2993
+ _ = options;
2994
+ // no-op
2995
+ }
2996
+
2997
+ pub fn failingDirHardLink(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8, options: Dir.HardLinkOptions) Dir.HardLinkError!void {
2998
+ _ = userdata;
2999
+ _ = old_dir;
3000
+ _ = old_sub_path;
3001
+ _ = new_dir;
3002
+ _ = new_sub_path;
3003
+ _ = options;
3004
+ return error.FileNotFound;
3005
+ }
3006
+
3007
+ pub fn failingFileStat(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
3008
+ _ = userdata;
3009
+ _ = file;
3010
+ return error.Streaming;
3011
+ }
3012
+
3013
+ pub fn failingFileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 {
3014
+ _ = userdata;
3015
+ _ = file;
3016
+ return error.Streaming;
3017
+ }
3018
+
3019
+ pub fn unreachableFileClose(userdata: ?*anyopaque, files: []const File) void {
3020
+ _ = userdata;
3021
+ _ = files;
3022
+ unreachable;
3023
+ }
3024
+
3025
+ pub fn failingFileWritePositional(userdata: ?*anyopaque, file: File, header: []const u8, data: []const []const u8, splat: usize, offset: u64) File.WritePositionalError!usize {
3026
+ _ = userdata;
3027
+ _ = file;
3028
+ _ = header;
3029
+ _ = offset;
3030
+ for (data[0 .. data.len - 1]) |item| {
3031
+ if (item.len > 0) return error.BrokenPipe;
3032
+ }
3033
+ if (data[data.len - 1].len != 0 and splat != 0) return error.BrokenPipe;
3034
+ return 0;
3035
+ }
3036
+
3037
+ pub fn noFileWriteFileStreaming(userdata: ?*anyopaque, file: File, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit) File.Writer.WriteFileError!usize {
3038
+ _ = userdata;
3039
+ _ = file;
3040
+ _ = header;
3041
+ _ = file_reader;
3042
+ _ = limit;
3043
+ return error.Unimplemented;
3044
+ }
3045
+
3046
+ pub fn noFileWriteFilePositional(userdata: ?*anyopaque, file: File, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit, offset: u64) File.WriteFilePositionalError!usize {
3047
+ _ = userdata;
3048
+ _ = file;
3049
+ _ = header;
3050
+ _ = file_reader;
3051
+ _ = limit;
3052
+ _ = offset;
3053
+ return error.Unimplemented;
3054
+ }
3055
+
3056
+ pub fn failingFileReadPositional(userdata: ?*anyopaque, file: File, data: []const []u8, offset: u64) File.ReadPositionalError!usize {
3057
+ _ = userdata;
3058
+ _ = file;
3059
+ _ = offset;
3060
+ for (data) |item| {
3061
+ if (item.len > 0) return error.InputOutput;
3062
+ }
3063
+ return 0;
3064
+ }
3065
+
3066
+ pub fn failingFileSeekBy(userdata: ?*anyopaque, file: File, relative_offset: i64) File.SeekError!void {
3067
+ _ = userdata;
3068
+ _ = file;
3069
+ _ = relative_offset;
3070
+ return error.Unseekable;
3071
+ }
3072
+
3073
+ pub fn failingFileSeekTo(userdata: ?*anyopaque, file: File, absolute_offset: u64) File.SeekError!void {
3074
+ _ = userdata;
3075
+ _ = file;
3076
+ _ = absolute_offset;
3077
+ return error.Unseekable;
3078
+ }
3079
+
3080
+ pub fn failingFileSync(userdata: ?*anyopaque, file: File) File.SyncError!void {
3081
+ _ = userdata;
3082
+ _ = file;
3083
+ return error.NoSpaceLeft;
3084
+ }
3085
+
3086
+ pub fn unreachableFileIsTty(userdata: ?*anyopaque, file: File) Cancelable!bool {
3087
+ _ = userdata;
3088
+ _ = file;
3089
+ unreachable;
3090
+ }
3091
+
3092
+ pub fn unreachableFileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: File) File.EnableAnsiEscapeCodesError!void {
3093
+ _ = userdata;
3094
+ _ = file;
3095
+ unreachable;
3096
+ }
3097
+
3098
+ pub fn unreachableFileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: File) Cancelable!bool {
3099
+ _ = userdata;
3100
+ _ = file;
3101
+ unreachable;
3102
+ }
3103
+
3104
+ pub fn failingFileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {
3105
+ _ = userdata;
3106
+ _ = file;
3107
+ _ = length;
3108
+ return error.NonResizable;
3109
+ }
3110
+
3111
+ pub fn failingFileSetOwner(userdata: ?*anyopaque, file: File, owner: ?File.Uid, group: ?File.Gid) File.SetOwnerError!void {
3112
+ _ = userdata;
3113
+ _ = file;
3114
+ _ = owner;
3115
+ _ = group;
3116
+ return error.FileNotFound;
3117
+ }
3118
+
3119
+ pub fn failingFileSetPermissions(userdata: ?*anyopaque, file: File, permissions: File.Permissions) File.SetPermissionsError!void {
3120
+ _ = userdata;
3121
+ _ = file;
3122
+ _ = permissions;
3123
+ return error.FileNotFound;
3124
+ }
3125
+
3126
+ pub fn noFileSetTimestamps(userdata: ?*anyopaque, file: File, options: File.SetTimestampsOptions) File.SetTimestampsError!void {
3127
+ _ = userdata;
3128
+ _ = file;
3129
+ _ = options;
3130
+ // no-op
3131
+ }
3132
+
3133
+ pub fn failingFileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!void {
3134
+ _ = userdata;
3135
+ _ = file;
3136
+ _ = lock;
3137
+ return error.FileLocksUnsupported;
3138
+ }
3139
+
3140
+ pub fn failingFileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!bool {
3141
+ _ = userdata;
3142
+ _ = file;
3143
+ _ = lock;
3144
+ return error.FileLocksUnsupported;
3145
+ }
3146
+
3147
+ pub fn unreachableFileUnlock(userdata: ?*anyopaque, file: File) void {
3148
+ _ = userdata;
3149
+ _ = file;
3150
+ unreachable;
3151
+ }
3152
+
3153
+ pub fn failingFileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!void {
3154
+ _ = userdata;
3155
+ _ = file;
3156
+ // no-op
3157
+ }
3158
+
3159
+ pub fn failingFileRealPath(userdata: ?*anyopaque, file: File, out_buffer: []u8) File.RealPathError!usize {
3160
+ _ = userdata;
3161
+ _ = file;
3162
+ _ = out_buffer;
3163
+ return error.FileNotFound;
3164
+ }
3165
+
3166
+ pub fn failingFileHardLink(userdata: ?*anyopaque, file: File, new_dir: Dir, new_sub_path: []const u8, options: File.HardLinkOptions) File.HardLinkError!void {
3167
+ _ = userdata;
3168
+ _ = file;
3169
+ _ = new_dir;
3170
+ _ = new_sub_path;
3171
+ _ = options;
3172
+ return error.FileNotFound;
3173
+ }
3174
+
3175
+ pub fn failingFileMemoryMapCreate(userdata: ?*anyopaque, file: File, options: File.MemoryMap.CreateOptions) File.MemoryMap.CreateError!File.MemoryMap {
3176
+ _ = userdata;
3177
+ _ = file;
3178
+ _ = options;
3179
+ return error.AccessDenied;
3180
+ }
3181
+
3182
+ pub fn unreachableFileMemoryMapDestroy(userdata: ?*anyopaque, mm: *File.MemoryMap) void {
3183
+ _ = userdata;
3184
+ _ = mm;
3185
+ unreachable;
3186
+ }
3187
+
3188
+ pub fn unreachableFileMemoryMapSetLength(userdata: ?*anyopaque, mm: *File.MemoryMap, new_len: usize) File.MemoryMap.SetLengthError!void {
3189
+ _ = userdata;
3190
+ _ = mm;
3191
+ _ = new_len;
3192
+ unreachable;
3193
+ }
3194
+
3195
+ pub fn unreachableFileMemoryMapRead(userdata: ?*anyopaque, mm: *File.MemoryMap) File.ReadPositionalError!void {
3196
+ _ = userdata;
3197
+ _ = mm;
3198
+ unreachable;
3199
+ }
3200
+
3201
+ pub fn unreachableFileMemoryMapWrite(userdata: ?*anyopaque, mm: *File.MemoryMap) File.WritePositionalError!void {
3202
+ _ = userdata;
3203
+ _ = mm;
3204
+ unreachable;
3205
+ }
3206
+
3207
+ pub fn failingProcessExecutableOpen(userdata: ?*anyopaque, flags: File.OpenFlags) std.process.OpenExecutableError!File {
3208
+ _ = userdata;
3209
+ _ = flags;
3210
+ return error.FileNotFound;
3211
+ }
3212
+
3213
+ pub fn failingProcessExecutablePath(userdata: ?*anyopaque, buffer: []u8) std.process.ExecutablePathError!usize {
3214
+ _ = userdata;
3215
+ _ = buffer;
3216
+ return error.FileNotFound;
3217
+ }
3218
+
3219
+ pub fn unreachableLockStderr(userdata: ?*anyopaque, terminal_mode: ?Terminal.Mode) Cancelable!LockedStderr {
3220
+ _ = userdata;
3221
+ _ = terminal_mode;
3222
+ unreachable;
3223
+ }
3224
+
3225
+ pub fn noTryLockStderr(userdata: ?*anyopaque, terminal_mode: ?Terminal.Mode) Cancelable!?LockedStderr {
3226
+ _ = userdata;
3227
+ _ = terminal_mode;
3228
+ return null;
3229
+ }
3230
+
3231
+ pub fn unreachableUnlockStderr(userdata: ?*anyopaque) void {
3232
+ _ = userdata;
3233
+ unreachable;
3234
+ }
3235
+
3236
+ pub fn failingProcessCurrentPath(userdata: ?*anyopaque, buffer: []u8) std.process.CurrentPathError!usize {
3237
+ _ = userdata;
3238
+ _ = buffer;
3239
+ return error.CurrentDirUnlinked;
3240
+ }
3241
+
3242
+ pub fn failingProcessSetCurrentDir(userdata: ?*anyopaque, dir: Dir) std.process.SetCurrentDirError!void {
3243
+ _ = userdata;
3244
+ _ = dir;
3245
+ return error.FileNotFound;
3246
+ }
3247
+
3248
+ pub fn failingProcessSetCurrentPath(userdata: ?*anyopaque, path: []const u8) std.process.SetCurrentPathError!void {
3249
+ _ = userdata;
3250
+ _ = path;
3251
+ return error.FileNotFound;
3252
+ }
3253
+
3254
+ pub fn failingProcessReplace(userdata: ?*anyopaque, options: std.process.ReplaceOptions) std.process.ReplaceError {
3255
+ _ = userdata;
3256
+ _ = options;
3257
+ return error.OperationUnsupported;
3258
+ }
3259
+
3260
+ pub fn failingProcessReplacePath(userdata: ?*anyopaque, dir: Dir, options: std.process.ReplaceOptions) std.process.ReplaceError {
3261
+ _ = userdata;
3262
+ _ = dir;
3263
+ _ = options;
3264
+ return error.OperationUnsupported;
3265
+ }
3266
+
3267
+ pub fn failingProcessSpawn(userdata: ?*anyopaque, options: std.process.SpawnOptions) std.process.SpawnError!std.process.Child {
3268
+ _ = userdata;
3269
+ _ = options;
3270
+ return error.OperationUnsupported;
3271
+ }
3272
+
3273
+ pub fn failingProcessSpawnPath(userdata: ?*anyopaque, dir: Dir, options: std.process.SpawnOptions) std.process.SpawnError!std.process.Child {
3274
+ _ = userdata;
3275
+ _ = dir;
3276
+ _ = options;
3277
+ return error.OperationUnsupported;
3278
+ }
3279
+
3280
+ pub fn unreachableChildWait(userdata: ?*anyopaque, child: *std.process.Child) std.process.Child.WaitError!std.process.Child.Term {
3281
+ _ = userdata;
3282
+ _ = child;
3283
+ unreachable;
3284
+ }
3285
+
3286
+ pub fn unreachableChildKill(userdata: ?*anyopaque, child: *std.process.Child) void {
3287
+ _ = userdata;
3288
+ _ = child;
3289
+ unreachable;
3290
+ }
3291
+
3292
+ pub fn failingProgressParentFile(userdata: ?*anyopaque) std.Progress.ParentFileError!File {
3293
+ _ = userdata;
3294
+ return error.UnsupportedOperation;
3295
+ }
3296
+
3297
+ pub fn noRandom(userdata: ?*anyopaque, buffer: []u8) void {
3298
+ _ = userdata;
3299
+ @memset(buffer, 0);
3300
+ }
3301
+
3302
+ pub fn failingRandomSecure(userdata: ?*anyopaque, buffer: []u8) RandomSecureError!void {
3303
+ _ = userdata;
3304
+ _ = buffer;
3305
+ return error.EntropyUnavailable;
3306
+ }
3307
+
3308
+ pub fn noNow(userdata: ?*anyopaque, clock: Clock) Timestamp {
3309
+ _ = userdata;
3310
+ _ = clock;
3311
+ return .zero;
3312
+ }
3313
+
3314
+ pub fn failingClockResolution(userdata: ?*anyopaque, clock: Clock) Clock.ResolutionError!Duration {
3315
+ _ = userdata;
3316
+ _ = clock;
3317
+ return error.ClockUnavailable;
3318
+ }
3319
+
3320
+ pub fn noSleep(userdata: ?*anyopaque, clock: Timeout) Cancelable!void {
3321
+ _ = userdata;
3322
+ _ = clock;
3323
+ }
3324
+
3325
+ pub fn failingNetListenIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.ListenOptions) net.IpAddress.ListenError!net.Socket {
3326
+ _ = userdata;
3327
+ _ = address;
3328
+ _ = options;
3329
+ return error.NetworkDown;
3330
+ }
3331
+
3332
+ pub fn failingNetAccept(userdata: ?*anyopaque, listen_fd: net.Socket.Handle, options: net.Server.AcceptOptions) net.Server.AcceptError!net.Socket {
3333
+ _ = userdata;
3334
+ _ = listen_fd;
3335
+ _ = options;
3336
+ return error.NetworkDown;
3337
+ }
3338
+
3339
+ pub fn failingNetBindIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.BindOptions) net.IpAddress.BindError!net.Socket {
3340
+ _ = userdata;
3341
+ _ = address;
3342
+ _ = options;
3343
+ return error.NetworkDown;
3344
+ }
3345
+
3346
+ pub fn failingNetConnectIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.ConnectOptions) net.IpAddress.ConnectError!net.Socket {
3347
+ _ = userdata;
3348
+ _ = address;
3349
+ _ = options;
3350
+ return error.NetworkDown;
3351
+ }
3352
+
3353
+ pub fn failingNetListenUnix(userdata: ?*anyopaque, address: *const net.UnixAddress, options: net.UnixAddress.ListenOptions) net.UnixAddress.ListenError!net.Socket.Handle {
3354
+ _ = userdata;
3355
+ _ = address;
3356
+ _ = options;
3357
+ return error.NetworkDown;
3358
+ }
3359
+
3360
+ pub fn failingNetConnectUnix(userdata: ?*anyopaque, address: *const net.UnixAddress) net.UnixAddress.ConnectError!net.Socket.Handle {
3361
+ _ = userdata;
3362
+ _ = address;
3363
+ return error.NetworkDown;
3364
+ }
3365
+
3366
+ pub fn failingNetSocketCreatePair(userdata: ?*anyopaque, options: net.Socket.CreatePairOptions) net.Socket.CreatePairError![2]net.Socket {
3367
+ _ = userdata;
3368
+ _ = options;
3369
+ return error.OperationUnsupported;
3370
+ }
3371
+
3372
+ pub fn failingNetSend(userdata: ?*anyopaque, handle: net.Socket.Handle, messages: []net.OutgoingMessage, flags: net.SendFlags) struct { ?net.Socket.SendError, usize } {
3373
+ _ = userdata;
3374
+ _ = handle;
3375
+ _ = messages;
3376
+ _ = flags;
3377
+ return .{ error.NetworkDown, 0 };
3378
+ }
3379
+
3380
+ pub fn failingNetRead(userdata: ?*anyopaque, src: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
3381
+ _ = userdata;
3382
+ _ = src;
3383
+ _ = data;
3384
+ return error.NetworkDown;
3385
+ }
3386
+
3387
+ pub fn failingNetWrite(userdata: ?*anyopaque, dest: net.Socket.Handle, header: []const u8, data: []const []const u8, splat: usize) net.Stream.Writer.Error!usize {
3388
+ _ = userdata;
3389
+ _ = dest;
3390
+ _ = header;
3391
+ _ = data;
3392
+ _ = splat;
3393
+ return error.NetworkDown;
3394
+ }
3395
+
3396
+ pub fn failingNetWriteFile(userdata: ?*anyopaque, handle: net.Socket.Handle, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit) net.Stream.Writer.WriteFileError!usize {
3397
+ _ = userdata;
3398
+ _ = handle;
3399
+ _ = header;
3400
+ _ = file_reader;
3401
+ _ = limit;
3402
+ return error.NetworkDown;
3403
+ }
3404
+
3405
+ pub fn unreachableNetClose(userdata: ?*anyopaque, handle: []const net.Socket.Handle) void {
3406
+ _ = userdata;
3407
+ _ = handle;
3408
+ unreachable;
3409
+ }
3410
+
3411
+ pub fn failingNetShutdown(userdata: ?*anyopaque, handle: net.Socket.Handle, how: net.ShutdownHow) net.ShutdownError!void {
3412
+ _ = userdata;
3413
+ _ = handle;
3414
+ _ = how;
3415
+ return error.NetworkDown;
3416
+ }
3417
+
3418
+ pub fn failingNetInterfaceNameResolve(userdata: ?*anyopaque, name: *const net.Interface.Name) net.Interface.Name.ResolveError!net.Interface {
3419
+ _ = userdata;
3420
+ _ = name;
3421
+ return error.InterfaceNotFound;
3422
+ }
3423
+
3424
+ pub fn unreachableNetInterfaceName(userdata: ?*anyopaque, interface: net.Interface) net.Interface.NameError!net.Interface.Name {
3425
+ _ = userdata;
3426
+ _ = interface;
3427
+ unreachable;
3428
+ }
3429
+
3430
+ pub fn failingNetLookup(userdata: ?*anyopaque, host_name: net.HostName, resolved: *Queue(net.HostName.LookupResult), options: net.HostName.LookupOptions) net.HostName.LookupError!void {
3431
+ _ = userdata;
3432
+ _ = host_name;
3433
+ _ = resolved;
3434
+ _ = options;
3435
+ return error.NetworkDown;
3436
+ }
3437
+
3438
+ test failing {
3439
+ const f: Io = .failing;
3440
+ // file stuff
3441
+ try std.testing.expectError(error.NoSpaceLeft, Dir.createDir(.cwd(), f, "test", .default_dir));
3442
+ try std.testing.expectError(error.NoSpaceLeft, Dir.createFile(.cwd(), f, "test", .{}));
3443
+ try std.testing.expectError(error.FileNotFound, Dir.openDir(.cwd(), f, "test", .{}));
3444
+ try std.testing.expectError(error.FileNotFound, Dir.openFile(.cwd(), f, "test", .{}));
3445
+ try File.writeStreamingAll(.stdout(), f, &.{});
3446
+ try std.testing.expectError(error.AccessDenied, File.MemoryMap.create(f, .stdout(), .{ .len = 0 }));
3447
+ // async stuff
3448
+ const closure = struct {
3449
+ var foo: usize = 0;
3450
+ fn doOp() void {
3451
+ foo = 4;
3452
+ }
3453
+ };
3454
+ var future = f.async(closure.doOp, .{});
3455
+ _ = future.await(f);
3456
+ try std.testing.expect(closure.foo == 4);
3457
+ // random stuff
3458
+ var buffer: [1]u8 = undefined;
3459
+ f.random(&buffer);
3460
+ try std.testing.expect(buffer[0] == 0);
3461
+ }
@@ -682,6 +682,40 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
682
682
  x30: bool = false,
683
683
  x31: bool = false,
684
684
 
685
+ // ABI aliases for integer registers
686
+ ra: bool = false,
687
+ sp: bool = false,
688
+ gp: bool = false,
689
+ tp: bool = false,
690
+ t0: bool = false,
691
+ t1: bool = false,
692
+ t2: bool = false,
693
+ s0: bool = false,
694
+ fp: bool = false,
695
+ s1: bool = false,
696
+ a0: bool = false,
697
+ a1: bool = false,
698
+ a2: bool = false,
699
+ a3: bool = false,
700
+ a4: bool = false,
701
+ a5: bool = false,
702
+ a6: bool = false,
703
+ a7: bool = false,
704
+ s2: bool = false,
705
+ s3: bool = false,
706
+ s4: bool = false,
707
+ s5: bool = false,
708
+ s6: bool = false,
709
+ s7: bool = false,
710
+ s8: bool = false,
711
+ s9: bool = false,
712
+ s10: bool = false,
713
+ s11: bool = false,
714
+ t3: bool = false,
715
+ t4: bool = false,
716
+ t5: bool = false,
717
+ t6: bool = false,
718
+
685
719
  fflags: bool = false,
686
720
  frm: bool = false,
687
721
 
@@ -718,6 +752,40 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
718
752
  f30: bool = false,
719
753
  f31: bool = false,
720
754
 
755
+ // ABI aliases for float registers
756
+ ft0: bool = false,
757
+ ft1: bool = false,
758
+ ft2: bool = false,
759
+ ft3: bool = false,
760
+ ft4: bool = false,
761
+ ft5: bool = false,
762
+ ft6: bool = false,
763
+ ft7: bool = false,
764
+ fs0: bool = false,
765
+ fs1: bool = false,
766
+ fa0: bool = false,
767
+ fa1: bool = false,
768
+ fa2: bool = false,
769
+ fa3: bool = false,
770
+ fa4: bool = false,
771
+ fa5: bool = false,
772
+ fa6: bool = false,
773
+ fa7: bool = false,
774
+ fs2: bool = false,
775
+ fs3: bool = false,
776
+ fs4: bool = false,
777
+ fs5: bool = false,
778
+ fs6: bool = false,
779
+ fs7: bool = false,
780
+ fs8: bool = false,
781
+ fs9: bool = false,
782
+ fs10: bool = false,
783
+ fs11: bool = false,
784
+ ft8: bool = false,
785
+ ft9: bool = false,
786
+ ft10: bool = false,
787
+ ft11: bool = false,
788
+
721
789
  vtype: bool = false,
722
790
  vl: bool = false,
723
791
  vxsat: bool = false,
package/std/enums.zig CHANGED
@@ -284,6 +284,18 @@ pub fn EnumSet(comptime E: type) type {
284
284
  /// A set containing all possible keys.
285
285
  pub const full: Self = .{ .bits = .full };
286
286
 
287
+ /// Deprecated: use `.empty`.
288
+ /// Returns a set containing no keys.
289
+ pub fn initEmpty() Self {
290
+ return .empty;
291
+ }
292
+
293
+ /// Deprecated: use `.full`.
294
+ /// Returns a set containing all possible keys.
295
+ pub fn initFull() Self {
296
+ return .full;
297
+ }
298
+
287
299
  /// Returns a set containing multiple keys.
288
300
  pub fn initMany(keys: []const Key) Self {
289
301
  var set: Self = .empty;
@@ -11,22 +11,6 @@ const c = std.c;
11
11
 
12
12
  pub const FILE = c.FILE;
13
13
 
14
- var __stack_chk_guard: usize = 0;
15
- fn __stack_chk_fail() callconv(.c) void {
16
- std.debug.print("stack smashing detected: terminated\n", .{});
17
- emscripten_force_exit(127);
18
- }
19
-
20
- comptime {
21
- if (builtin.os.tag == .emscripten) {
22
- if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) {
23
- // Emscripten does not provide these symbols, so we must export our own
24
- @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong });
25
- @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong });
26
- }
27
- }
28
- }
29
-
30
14
  pub const PF = linux.PF;
31
15
  pub const AF = linux.AF;
32
16
  pub const CLOCK = linux.CLOCK;
package/std/posix.zig CHANGED
@@ -513,6 +513,9 @@ pub const GetSockNameError = error{
513
513
  SocketNotBound,
514
514
 
515
515
  FileDescriptorNotASocket,
516
+
517
+ /// The socket is not connected (connection-oriented sockets only).
518
+ SocketUnconnected,
516
519
  } || UnexpectedError;
517
520
 
518
521
  pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSockNameError!void {
@@ -529,6 +532,7 @@ pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSock
529
532
  .INVAL => unreachable, // invalid parameters
530
533
  .NOTSOCK => return error.FileDescriptorNotASocket,
531
534
  .NOBUFS => return error.SystemResources,
535
+ .NOTCONN => return error.SocketUnconnected,
532
536
  }
533
537
  }
534
538
  }