@zigc/lib 0.16.0-test.1 → 0.17.0-dev.9

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.
Files changed (242) hide show
  1. package/LICENSE +19 -0
  2. package/c/math.zig +135 -35
  3. package/c/stropts.zig +17 -0
  4. package/c.zig +1 -0
  5. package/compiler/aro/aro/Attribute/names.zig +604 -589
  6. package/compiler/aro/aro/Attribute.zig +202 -116
  7. package/compiler/aro/aro/Builtins/common.zig +874 -863
  8. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  9. package/compiler/aro/aro/Builtins.zig +0 -1
  10. package/compiler/aro/aro/CodeGen.zig +3 -1
  11. package/compiler/aro/aro/Compilation.zig +120 -97
  12. package/compiler/aro/aro/Diagnostics.zig +21 -17
  13. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  14. package/compiler/aro/aro/Driver.zig +124 -50
  15. package/compiler/aro/aro/LangOpts.zig +12 -2
  16. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  17. package/compiler/aro/aro/Parser.zig +336 -142
  18. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  19. package/compiler/aro/aro/Preprocessor.zig +127 -56
  20. package/compiler/aro/aro/Target.zig +17 -12
  21. package/compiler/aro/aro/Tokenizer.zig +31 -14
  22. package/compiler/aro/aro/Toolchain.zig +4 -7
  23. package/compiler/aro/aro/Tree.zig +178 -148
  24. package/compiler/aro/aro/TypeStore.zig +82 -24
  25. package/compiler/aro/aro/Value.zig +13 -17
  26. package/compiler/aro/aro/features.zig +1 -0
  27. package/compiler/aro/aro/pragmas/once.zig +0 -1
  28. package/compiler/aro/aro/record_layout.zig +3 -3
  29. package/compiler/aro/assembly_backend/x86_64.zig +3 -4
  30. package/compiler/aro/backend/Assembly.zig +1 -2
  31. package/compiler/aro/backend/Interner.zig +2 -2
  32. package/compiler/aro/backend/Ir.zig +100 -92
  33. package/compiler/aro/include/ptrcheck.h +49 -0
  34. package/compiler/aro/main.zig +26 -10
  35. package/compiler/build_runner.zig +1 -0
  36. package/compiler/objdump.zig +93 -0
  37. package/compiler/reduce.zig +5 -1
  38. package/compiler/resinator/compile.zig +2 -2
  39. package/compiler/resinator/main.zig +7 -1
  40. package/compiler/resinator/preprocess.zig +1 -3
  41. package/compiler/std-docs.zig +8 -1
  42. package/compiler/test_runner.zig +193 -61
  43. package/compiler/translate-c/MacroTranslator.zig +80 -11
  44. package/compiler/translate-c/PatternList.zig +1 -9
  45. package/compiler/translate-c/Scope.zig +43 -6
  46. package/compiler/translate-c/Translator.zig +364 -126
  47. package/compiler/translate-c/ast.zig +19 -11
  48. package/compiler/translate-c/main.zig +75 -16
  49. package/compiler_rt/cos.zig +141 -52
  50. package/compiler_rt/limb64.zig +266 -0
  51. package/compiler_rt/long_double.zig +37 -0
  52. package/compiler_rt/mulo.zig +6 -1
  53. package/compiler_rt/rem_pio2l.zig +173 -0
  54. package/compiler_rt/sin.zig +140 -55
  55. package/compiler_rt/sincos.zig +279 -72
  56. package/compiler_rt/tan.zig +118 -47
  57. package/compiler_rt/trig.zig +256 -6
  58. package/compiler_rt.zig +2 -0
  59. package/fuzzer.zig +855 -307
  60. package/libc/musl/src/math/pow.c +343 -0
  61. package/package.json +1 -1
  62. package/std/Build/Fuzz.zig +6 -19
  63. package/std/Build/Module.zig +1 -1
  64. package/std/Build/Step/CheckObject.zig +3 -3
  65. package/std/Build/Step/Compile.zig +18 -0
  66. package/std/Build/Step/ConfigHeader.zig +49 -33
  67. package/std/Build/Step/InstallArtifact.zig +18 -0
  68. package/std/Build/Step/Run.zig +536 -87
  69. package/std/Build/Step/TranslateC.zig +0 -6
  70. package/std/Build/Step.zig +8 -15
  71. package/std/Build/WebServer.zig +29 -17
  72. package/std/Build/abi.zig +47 -11
  73. package/std/Build.zig +17 -14
  74. package/std/Io/Dispatch.zig +2 -0
  75. package/std/Io/File/Reader.zig +3 -1
  76. package/std/Io/File.zig +1 -0
  77. package/std/Io/Kqueue.zig +2 -2
  78. package/std/Io/Threaded.zig +181 -143
  79. package/std/Io/Uring.zig +2 -1
  80. package/std/Io.zig +970 -2
  81. package/std/Target.zig +3 -2
  82. package/std/Thread.zig +8 -3
  83. package/std/array_hash_map.zig +96 -555
  84. package/std/array_list.zig +22 -31
  85. package/std/bit_set.zig +22 -6
  86. package/std/builtin/assembly.zig +68 -0
  87. package/std/c.zig +17 -17
  88. package/std/compress/flate/Compress.zig +3 -3
  89. package/std/crypto/Certificate/Bundle.zig +15 -1
  90. package/std/crypto/codecs/asn1.zig +33 -18
  91. package/std/crypto/codecs/base64_hex_ct.zig +14 -4
  92. package/std/debug/Dwarf.zig +29 -9
  93. package/std/debug/Info.zig +4 -0
  94. package/std/debug/MachOFile.zig +46 -8
  95. package/std/debug/Pdb.zig +539 -36
  96. package/std/debug/SelfInfo/Elf.zig +19 -18
  97. package/std/debug/SelfInfo/MachO.zig +18 -7
  98. package/std/debug/SelfInfo/Windows.zig +138 -36
  99. package/std/debug.zig +179 -65
  100. package/std/enums.zig +25 -19
  101. package/std/heap/ArenaAllocator.zig +145 -154
  102. package/std/heap/debug_allocator.zig +7 -7
  103. package/std/http/Client.zig +10 -6
  104. package/std/http.zig +11 -9
  105. package/std/json/Stringify.zig +3 -3
  106. package/std/json/dynamic.zig +4 -4
  107. package/std/math/big/int.zig +16 -17
  108. package/std/mem/Allocator.zig +4 -5
  109. package/std/mem.zig +48 -0
  110. package/std/os/emscripten.zig +2 -18
  111. package/std/os/linux/arc.zig +144 -0
  112. package/std/os/linux.zig +21 -4
  113. package/std/os/windows.zig +2 -2
  114. package/std/pdb.zig +143 -4
  115. package/std/posix.zig +6 -12
  116. package/std/priority_dequeue.zig +13 -12
  117. package/std/priority_queue.zig +5 -4
  118. package/std/process/Child.zig +1 -1
  119. package/std/process/Environ.zig +1 -1
  120. package/std/start.zig +17 -4
  121. package/std/std.zig +19 -6
  122. package/std/testing/FailingAllocator.zig +4 -4
  123. package/std/testing/Smith.zig +37 -2
  124. package/std/zig/Ast/Render.zig +186 -458
  125. package/std/zig/Ast.zig +0 -4
  126. package/std/zig/AstGen.zig +44 -7
  127. package/std/zig/AstSmith.zig +2602 -0
  128. package/std/zig/Client.zig +8 -3
  129. package/std/zig/Parse.zig +83 -74
  130. package/std/zig/Server.zig +26 -0
  131. package/std/zig/Zir.zig +17 -0
  132. package/std/zig/c_translation/helpers.zig +14 -9
  133. package/std/zig/llvm/Builder.zig +107 -48
  134. package/std/zig/system.zig +20 -4
  135. package/std/zig/tokenizer.zig +2 -1
  136. package/std/zig.zig +6 -0
  137. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  138. package/libc/mingw/complex/cabs.c +0 -48
  139. package/libc/mingw/complex/cabsf.c +0 -48
  140. package/libc/mingw/complex/cacos.c +0 -50
  141. package/libc/mingw/complex/cacosf.c +0 -50
  142. package/libc/mingw/complex/carg.c +0 -48
  143. package/libc/mingw/complex/cargf.c +0 -48
  144. package/libc/mingw/complex/casin.c +0 -50
  145. package/libc/mingw/complex/casinf.c +0 -50
  146. package/libc/mingw/complex/catan.c +0 -50
  147. package/libc/mingw/complex/catanf.c +0 -50
  148. package/libc/mingw/complex/ccos.c +0 -50
  149. package/libc/mingw/complex/ccosf.c +0 -50
  150. package/libc/mingw/complex/cexp.c +0 -48
  151. package/libc/mingw/complex/cexpf.c +0 -48
  152. package/libc/mingw/complex/cimag.c +0 -48
  153. package/libc/mingw/complex/cimagf.c +0 -48
  154. package/libc/mingw/complex/clog.c +0 -48
  155. package/libc/mingw/complex/clog10.c +0 -49
  156. package/libc/mingw/complex/clog10f.c +0 -49
  157. package/libc/mingw/complex/clogf.c +0 -48
  158. package/libc/mingw/complex/conj.c +0 -48
  159. package/libc/mingw/complex/conjf.c +0 -48
  160. package/libc/mingw/complex/cpow.c +0 -48
  161. package/libc/mingw/complex/cpowf.c +0 -48
  162. package/libc/mingw/complex/cproj.c +0 -48
  163. package/libc/mingw/complex/cprojf.c +0 -48
  164. package/libc/mingw/complex/creal.c +0 -48
  165. package/libc/mingw/complex/crealf.c +0 -48
  166. package/libc/mingw/complex/csin.c +0 -50
  167. package/libc/mingw/complex/csinf.c +0 -50
  168. package/libc/mingw/complex/csqrt.c +0 -48
  169. package/libc/mingw/complex/csqrtf.c +0 -48
  170. package/libc/mingw/complex/ctan.c +0 -50
  171. package/libc/mingw/complex/ctanf.c +0 -50
  172. package/libc/mingw/math/arm/s_rint.c +0 -86
  173. package/libc/mingw/math/arm/s_rintf.c +0 -51
  174. package/libc/mingw/math/arm/sincos.S +0 -30
  175. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  176. package/libc/mingw/math/arm64/rint.c +0 -12
  177. package/libc/mingw/math/arm64/rintf.c +0 -12
  178. package/libc/mingw/math/arm64/sincos.S +0 -32
  179. package/libc/mingw/math/bsd_private_base.h +0 -148
  180. package/libc/mingw/math/frexpf.c +0 -13
  181. package/libc/mingw/math/frexpl.c +0 -71
  182. package/libc/mingw/math/x86/acosf.c +0 -29
  183. package/libc/mingw/math/x86/atanf.c +0 -23
  184. package/libc/mingw/math/x86/atanl.c +0 -18
  185. package/libc/mingw/math/x86/cos.def.h +0 -65
  186. package/libc/mingw/math/x86/cosl.c +0 -46
  187. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  188. package/libc/mingw/math/x86/ldexp.c +0 -23
  189. package/libc/mingw/math/x86/scalbn.S +0 -41
  190. package/libc/mingw/math/x86/scalbnf.S +0 -40
  191. package/libc/mingw/math/x86/sin.def.h +0 -65
  192. package/libc/mingw/math/x86/sinl.c +0 -46
  193. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  194. package/libc/mingw/math/x86/tanl.S +0 -62
  195. package/libc/mingw/misc/btowc.c +0 -28
  196. package/libc/mingw/misc/wcstof.c +0 -66
  197. package/libc/mingw/misc/wcstoimax.c +0 -132
  198. package/libc/mingw/misc/wcstoumax.c +0 -126
  199. package/libc/mingw/misc/wctob.c +0 -29
  200. package/libc/mingw/misc/winbs_uint64.c +0 -6
  201. package/libc/mingw/misc/winbs_ulong.c +0 -6
  202. package/libc/mingw/misc/winbs_ushort.c +0 -6
  203. package/libc/mingw/stdio/_Exit.c +0 -10
  204. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  205. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  206. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  207. package/libc/mingw/stdio/_stat64i32.c +0 -37
  208. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  209. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  210. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  211. package/libc/musl/src/legacy/isastream.c +0 -7
  212. package/libc/musl/src/legacy/valloc.c +0 -8
  213. package/libc/musl/src/math/__cosl.c +0 -96
  214. package/libc/musl/src/math/__sinl.c +0 -78
  215. package/libc/musl/src/math/__tanl.c +0 -143
  216. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  217. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  218. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  219. package/libc/musl/src/math/cosl.c +0 -39
  220. package/libc/musl/src/math/fdim.c +0 -10
  221. package/libc/musl/src/math/finite.c +0 -7
  222. package/libc/musl/src/math/finitef.c +0 -7
  223. package/libc/musl/src/math/frexp.c +0 -23
  224. package/libc/musl/src/math/frexpf.c +0 -23
  225. package/libc/musl/src/math/frexpl.c +0 -29
  226. package/libc/musl/src/math/i386/lrint.c +0 -8
  227. package/libc/musl/src/math/i386/lrintf.c +0 -8
  228. package/libc/musl/src/math/i386/rintf.c +0 -7
  229. package/libc/musl/src/math/lrint.c +0 -72
  230. package/libc/musl/src/math/lrintf.c +0 -8
  231. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  232. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  233. package/libc/musl/src/math/rintf.c +0 -30
  234. package/libc/musl/src/math/s390x/rintf.c +0 -15
  235. package/libc/musl/src/math/sincosl.c +0 -60
  236. package/libc/musl/src/math/sinl.c +0 -41
  237. package/libc/musl/src/math/tanl.c +0 -29
  238. package/libc/musl/src/math/x32/lrint.s +0 -5
  239. package/libc/musl/src/math/x32/lrintf.s +0 -5
  240. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  241. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  242. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
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 };
@@ -500,8 +507,8 @@ pub const Batch = struct {
500
507
  /// Returns the index that will be returned by `next` after the operation completes.
501
508
  /// Asserts that no more than `storage.len` operations are active at a time.
502
509
  pub fn add(batch: *Batch, operation: Operation) u32 {
503
- const index = batch.unused.next;
504
- batch.addAt(index.toIndex(), operation);
510
+ const index = batch.unused.head.toIndex();
511
+ batch.addAt(index, operation);
505
512
  return index;
506
513
  }
507
514
 
@@ -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
+ }