@zigc/lib 0.16.0 → 0.17.0-dev.135

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 (268) hide show
  1. package/c/fcntl.zig +6 -1
  2. package/c/inttypes.zig +0 -10
  3. package/c/math.zig +46 -122
  4. package/c/pthread.zig +57 -0
  5. package/c/search.zig +1 -27
  6. package/c/stdlib/drand48.zig +0 -57
  7. package/c/stdlib.zig +0 -100
  8. package/c/string.zig +20 -7
  9. package/c/strings.zig +0 -38
  10. package/c/unistd.zig +27 -26
  11. package/c/wchar.zig +10 -0
  12. package/c.zig +2 -2
  13. package/compiler/aro/aro/CodeGen.zig +5 -6
  14. package/compiler/aro/aro/Compilation.zig +17 -14
  15. package/compiler/aro/aro/Driver.zig +14 -13
  16. package/compiler/aro/aro/Parser.zig +20 -15
  17. package/compiler/aro/aro/Pragma.zig +3 -2
  18. package/compiler/aro/aro/Preprocessor.zig +9 -6
  19. package/compiler/aro/aro/pragmas/message.zig +3 -2
  20. package/compiler/aro/aro/text_literal.zig +3 -2
  21. package/compiler/aro/assembly_backend/x86_64.zig +4 -4
  22. package/compiler/build_runner.zig +0 -2
  23. package/compiler/reduce/Walk.zig +7 -7
  24. package/compiler/test_runner.zig +2 -2
  25. package/compiler/translate-c/Translator.zig +6 -2
  26. package/compiler/translate-c/main.zig +1 -1
  27. package/compiler_rt/cos.zig +0 -2
  28. package/compiler_rt/divmodei4.zig +40 -17
  29. package/compiler_rt/exp.zig +1 -6
  30. package/compiler_rt/exp2.zig +1 -6
  31. package/compiler_rt/exp_f128.zig +377 -0
  32. package/compiler_rt/fabs.zig +0 -2
  33. package/compiler_rt/fma.zig +0 -2
  34. package/compiler_rt/fmax.zig +0 -2
  35. package/compiler_rt/fmin.zig +0 -2
  36. package/compiler_rt/fmod.zig +0 -2
  37. package/compiler_rt/limb64.zig +876 -15
  38. package/compiler_rt/log.zig +0 -2
  39. package/compiler_rt/log10.zig +0 -2
  40. package/compiler_rt/log2.zig +0 -2
  41. package/compiler_rt/mulXi3.zig +1 -1
  42. package/compiler_rt/round.zig +0 -2
  43. package/compiler_rt/sin.zig +0 -2
  44. package/compiler_rt/sincos.zig +0 -2
  45. package/compiler_rt/sqrt.zig +0 -2
  46. package/compiler_rt/ssp.zig +1 -1
  47. package/compiler_rt/tan.zig +0 -2
  48. package/compiler_rt/trunc.zig +0 -2
  49. package/compiler_rt/udivmodei4.zig +28 -0
  50. package/fuzzer.zig +2 -0
  51. package/libc/include/aarch64-linux-any/asm/hwcap.h +1 -0
  52. package/libc/include/aarch64-linux-any/asm/unistd_64.h +1 -0
  53. package/libc/include/any-linux-any/asm-generic/errno.h +2 -0
  54. package/libc/include/any-linux-any/asm-generic/unistd.h +4 -1
  55. package/libc/include/any-linux-any/drm/amdgpu_drm.h +20 -6
  56. package/libc/include/any-linux-any/drm/amdxdna_accel.h +8 -0
  57. package/libc/include/any-linux-any/drm/drm_fourcc.h +6 -6
  58. package/libc/include/any-linux-any/drm/panfrost_drm.h +75 -1
  59. package/libc/include/any-linux-any/drm/panthor_drm.h +154 -3
  60. package/libc/include/any-linux-any/drm/rocket_accel.h +74 -24
  61. package/libc/include/any-linux-any/drm/xe_drm.h +89 -6
  62. package/libc/include/any-linux-any/linux/android/binder.h +1 -1
  63. package/libc/include/any-linux-any/linux/bpf.h +28 -0
  64. package/libc/include/any-linux-any/linux/btrfs.h +1 -0
  65. package/libc/include/any-linux-any/linux/btrfs_tree.h +32 -2
  66. package/libc/include/any-linux-any/linux/dma-buf.h +1 -0
  67. package/libc/include/any-linux-any/linux/dpll.h +1 -0
  68. package/libc/include/any-linux-any/linux/elf.h +2 -0
  69. package/libc/include/any-linux-any/linux/ethtool.h +21 -5
  70. package/libc/include/any-linux-any/linux/fs.h +1 -0
  71. package/libc/include/any-linux-any/linux/hyperv.h +1 -1
  72. package/libc/include/any-linux-any/linux/idxd.h +134 -134
  73. package/libc/include/any-linux-any/linux/if_alg.h +1 -1
  74. package/libc/include/any-linux-any/linux/if_link.h +1 -0
  75. package/libc/include/any-linux-any/linux/input-event-codes.h +4 -0
  76. package/libc/include/any-linux-any/linux/io_uring/bpf_filter.h +68 -0
  77. package/libc/include/any-linux-any/linux/io_uring/query.h +5 -1
  78. package/libc/include/any-linux-any/linux/io_uring.h +33 -2
  79. package/libc/include/any-linux-any/linux/iommufd.h +39 -0
  80. package/libc/include/any-linux-any/linux/kfd_ioctl.h +13 -3
  81. package/libc/include/any-linux-any/linux/kfd_sysfs.h +2 -1
  82. package/libc/include/any-linux-any/linux/kvm.h +30 -6
  83. package/libc/include/any-linux-any/linux/landlock.h +22 -8
  84. package/libc/include/any-linux-any/linux/magic.h +1 -0
  85. package/libc/include/any-linux-any/linux/mempolicy.h +3 -0
  86. package/libc/include/any-linux-any/linux/mount.h +11 -2
  87. package/libc/include/any-linux-any/linux/mptcp_pm.h +1 -1
  88. package/libc/include/any-linux-any/linux/mshv.h +2 -0
  89. package/libc/include/any-linux-any/linux/netfilter_bridge.h +5 -4
  90. package/libc/include/any-linux-any/linux/netfilter_ipv4.h +4 -5
  91. package/libc/include/any-linux-any/linux/netfilter_ipv6.h +3 -4
  92. package/libc/include/any-linux-any/linux/nfs.h +1 -1
  93. package/libc/include/any-linux-any/linux/nfsd_netlink.h +1 -0
  94. package/libc/include/any-linux-any/linux/nilfs2_api.h +2 -2
  95. package/libc/include/any-linux-any/linux/nilfs2_ondisk.h +97 -66
  96. package/libc/include/any-linux-any/linux/nl80211.h +104 -3
  97. package/libc/include/any-linux-any/linux/pci.h +7 -0
  98. package/libc/include/any-linux-any/linux/pci_regs.h +65 -6
  99. package/libc/include/any-linux-any/linux/pcitest.h +1 -0
  100. package/libc/include/any-linux-any/linux/perf_event.h +24 -3
  101. package/libc/include/any-linux-any/linux/pkt_sched.h +1 -0
  102. package/libc/include/any-linux-any/linux/prctl.h +30 -0
  103. package/libc/include/any-linux-any/linux/rseq.h +62 -5
  104. package/libc/include/any-linux-any/linux/shm.h +0 -1
  105. package/libc/include/any-linux-any/linux/stddef.h +4 -0
  106. package/libc/include/any-linux-any/linux/sysctl.h +1 -2
  107. package/libc/include/any-linux-any/linux/taskstats.h +12 -1
  108. package/libc/include/any-linux-any/linux/tcp.h +23 -3
  109. package/libc/include/any-linux-any/linux/typelimits.h +8 -0
  110. package/libc/include/any-linux-any/linux/ublk_cmd.h +120 -1
  111. package/libc/include/any-linux-any/linux/v4l2-controls.h +63 -0
  112. package/libc/include/any-linux-any/linux/vbox_vmmdev_types.h +2 -2
  113. package/libc/include/any-linux-any/linux/vduse.h +80 -5
  114. package/libc/include/any-linux-any/linux/version.h +3 -3
  115. package/libc/include/any-linux-any/linux/vfio.h +4 -0
  116. package/libc/include/any-linux-any/linux/videodev2.h +3 -0
  117. package/libc/include/any-linux-any/linux/virtio_ring.h +1 -2
  118. package/libc/include/any-linux-any/linux/vmclock-abi.h +20 -0
  119. package/libc/include/any-linux-any/rdma/bnxt_re-abi.h +16 -0
  120. package/libc/include/any-linux-any/rdma/ib_user_ioctl_cmds.h +16 -0
  121. package/libc/include/any-linux-any/rdma/mana-abi.h +3 -0
  122. package/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h +8 -9
  123. package/libc/include/any-linux-any/sound/sof/tokens.h +6 -0
  124. package/libc/include/arc-linux-any/asm/swab.h +0 -63
  125. package/libc/include/arc-linux-any/asm/unistd_32.h +1 -0
  126. package/libc/include/arm-linux-any/asm/ptrace.h +0 -9
  127. package/libc/include/arm-linux-any/asm/unistd-eabi.h +1 -0
  128. package/libc/include/arm-linux-any/asm/unistd-oabi.h +1 -0
  129. package/libc/include/csky-linux-any/asm/unistd_32.h +1 -0
  130. package/libc/include/hexagon-linux-any/asm/unistd_32.h +1 -0
  131. package/libc/include/loongarch-linux-any/asm/hwcap.h +1 -0
  132. package/libc/include/loongarch-linux-any/asm/kvm.h +1 -0
  133. package/libc/include/loongarch-linux-any/asm/kvm_para.h +1 -0
  134. package/libc/include/loongarch-linux-any/asm/unistd_32.h +2 -0
  135. package/libc/include/loongarch-linux-any/asm/unistd_64.h +2 -0
  136. package/libc/include/m68k-linux-any/asm/unistd_32.h +1 -0
  137. package/libc/include/mips-linux-any/asm/errno.h +2 -0
  138. package/libc/include/mips-linux-any/asm/unistd_n32.h +1 -0
  139. package/libc/include/mips-linux-any/asm/unistd_n64.h +1 -0
  140. package/libc/include/mips-linux-any/asm/unistd_o32.h +1 -0
  141. package/libc/include/powerpc-linux-any/asm/unistd_32.h +1 -0
  142. package/libc/include/powerpc-linux-any/asm/unistd_64.h +1 -0
  143. package/libc/include/riscv-linux-any/asm/hwprobe.h +4 -0
  144. package/libc/include/riscv-linux-any/asm/kvm.h +3 -0
  145. package/libc/include/riscv-linux-any/asm/ptrace.h +37 -0
  146. package/libc/include/riscv-linux-any/asm/sigcontext.h +1 -0
  147. package/libc/include/riscv-linux-any/asm/unistd_32.h +1 -0
  148. package/libc/include/riscv-linux-any/asm/unistd_64.h +1 -0
  149. package/libc/include/s390x-linux-any/asm/unistd_64.h +1 -0
  150. package/libc/include/sparc-linux-any/asm/errno.h +2 -0
  151. package/libc/include/sparc-linux-any/asm/ioctls.h +4 -4
  152. package/libc/include/sparc-linux-any/asm/unistd_32.h +2 -0
  153. package/libc/include/sparc-linux-any/asm/unistd_64.h +2 -0
  154. package/libc/include/x86-linux-any/asm/auxvec.h +0 -4
  155. package/libc/include/x86-linux-any/asm/kvm.h +13 -8
  156. package/libc/include/x86-linux-any/asm/svm.h +16 -16
  157. package/libc/include/x86-linux-any/asm/unistd_32.h +1 -0
  158. package/libc/include/x86-linux-any/asm/unistd_64.h +1 -0
  159. package/libc/include/x86-linux-any/asm/unistd_x32.h +1 -0
  160. package/libc/include/xtensa-linux-any/asm/unistd_32.h +1 -0
  161. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  162. package/package.json +1 -1
  163. package/std/Build/Cache.zig +6 -6
  164. package/std/Build/Step/Compile.zig +0 -1
  165. package/std/Build/Step/Run.zig +2 -2
  166. package/std/Build/Step.zig +2 -4
  167. package/std/Build/WebServer.zig +2 -2
  168. package/std/Build.zig +0 -3
  169. package/std/Io/Dir.zig +7 -2
  170. package/std/Io/Dispatch.zig +3 -13
  171. package/std/Io/File/Writer.zig +8 -6
  172. package/std/Io/Reader.zig +8 -9
  173. package/std/Io/Semaphore.zig +112 -17
  174. package/std/Io/Terminal.zig +1 -1
  175. package/std/Io/Threaded.zig +171 -37
  176. package/std/Io/Uring.zig +13 -15
  177. package/std/Io/Writer.zig +46 -42
  178. package/std/Io/net.zig +11 -11
  179. package/std/Io.zig +90 -26
  180. package/std/SemanticVersion.zig +1 -1
  181. package/std/Target/Query.zig +2 -2
  182. package/std/Target.zig +50 -5
  183. package/std/array_hash_map.zig +9 -18
  184. package/std/builtin.zig +4 -0
  185. package/std/c/haiku.zig +3 -0
  186. package/std/c/serenity.zig +1 -6
  187. package/std/c.zig +89 -7
  188. package/std/compress/flate/Decompress.zig +2 -3
  189. package/std/compress/zstd/Decompress.zig +2 -4
  190. package/std/crypto/Certificate.zig +13 -1
  191. package/std/crypto/ascon.zig +75 -33
  192. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  193. package/std/crypto/codecs/base64_hex_ct.zig +2 -4
  194. package/std/crypto/ml_kem.zig +2 -9
  195. package/std/crypto/tls/Client.zig +79 -4
  196. package/std/crypto/tls.zig +1 -1
  197. package/std/crypto.zig +1 -0
  198. package/std/debug/Pdb.zig +1 -1
  199. package/std/debug.zig +4 -3
  200. package/std/fmt.zig +8 -3
  201. package/std/fs/path.zig +6 -4
  202. package/std/heap/BufferFirstAllocator.zig +165 -0
  203. package/std/heap.zig +2 -126
  204. package/std/http/Client.zig +21 -24
  205. package/std/http.zig +3 -4
  206. package/std/json/Scanner.zig +2 -2
  207. package/std/os/emscripten.zig +1 -1
  208. package/std/os/linux/IoUring.zig +2 -0
  209. package/std/os/linux/aarch64.zig +41 -12
  210. package/std/os/linux/arc.zig +173 -0
  211. package/std/os/linux/arm.zig +41 -12
  212. package/std/os/linux/hexagon.zig +33 -11
  213. package/std/os/linux/loongarch32.zig +41 -13
  214. package/std/os/linux/loongarch64.zig +41 -12
  215. package/std/os/linux/m68k.zig +41 -13
  216. package/std/os/linux/mips.zig +67 -36
  217. package/std/os/linux/mips64.zig +60 -29
  218. package/std/os/linux/mipsn32.zig +60 -29
  219. package/std/os/linux/or1k.zig +41 -12
  220. package/std/os/linux/powerpc.zig +41 -12
  221. package/std/os/linux/powerpc64.zig +41 -12
  222. package/std/os/linux/riscv32.zig +41 -12
  223. package/std/os/linux/riscv64.zig +41 -12
  224. package/std/os/linux/s390x.zig +44 -7
  225. package/std/os/linux/sparc64.zig +83 -52
  226. package/std/os/linux/syscalls.zig +26 -1
  227. package/std/os/linux/thumb.zig +52 -36
  228. package/std/os/linux/x32.zig +41 -12
  229. package/std/os/linux/x86.zig +42 -13
  230. package/std/os/linux/x86_64.zig +41 -12
  231. package/std/os/linux.zig +412 -436
  232. package/std/os/uefi/tables/boot_services.zig +9 -8
  233. package/std/os.zig +41 -0
  234. package/std/process.zig +1 -1
  235. package/std/sort.zig +3 -3
  236. package/std/zig/Ast/Render.zig +3 -3
  237. package/std/zig/AstGen.zig +44 -98
  238. package/std/zig/AstRlAnnotate.zig +0 -11
  239. package/std/zig/BuiltinFn.zig +0 -32
  240. package/std/zig/LibCInstallation.zig +4 -3
  241. package/std/zig/Parse.zig +7 -7
  242. package/std/zig/WindowsSdk.zig +13 -13
  243. package/std/zig/Zir.zig +50 -63
  244. package/std/zig/ZonGen.zig +6 -5
  245. package/std/zig/llvm/Builder.zig +12 -12
  246. package/std/zig.zig +1 -10
  247. package/std/zip.zig +5 -5
  248. package/zig.h +340 -1
  249. package/libc/include/hexagon-linux-any/asm/signal.h +0 -29
  250. package/libc/include/s390x-linux-any/asm/tape390.h +0 -103
  251. package/libc/mingw/math/fdiml.c +0 -24
  252. package/libc/mingw/winpthreads/spinlock.c +0 -82
  253. package/libc/musl/src/linux/tee.c +0 -8
  254. package/libc/musl/src/math/fdimf.c +0 -10
  255. package/libc/musl/src/math/fdiml.c +0 -18
  256. package/libc/musl/src/string/strdup.c +0 -10
  257. package/libc/musl/src/string/strndup.c +0 -12
  258. package/libc/musl/src/string/wcsdup.c +0 -10
  259. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  260. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  261. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  262. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  263. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  264. package/libc/musl/src/unistd/dup2.c +0 -20
  265. package/libc/musl/src/unistd/dup3.c +0 -26
  266. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  267. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  268. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
@@ -1943,10 +1943,6 @@ pub fn io(t: *Threaded) Io {
1943
1943
  .windows => netShutdownWindows,
1944
1944
  else => netShutdownPosix,
1945
1945
  },
1946
- .netRead = switch (native_os) {
1947
- .windows => netReadWindows,
1948
- else => netReadPosix,
1949
- },
1950
1946
  .netWrite = switch (native_os) {
1951
1947
  .windows => netWriteWindows,
1952
1948
  else => netWritePosix,
@@ -2009,7 +2005,7 @@ const have_waitid = switch (native_os) {
2009
2005
 
2010
2006
  const have_wait4 = switch (native_os) {
2011
2007
  .linux => @hasField(std.os.linux.SYS, "wait4"),
2012
- .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => true,
2008
+ .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => true,
2013
2009
  else => false,
2014
2010
  };
2015
2011
 
@@ -2566,6 +2562,12 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
2566
2562
  };
2567
2563
  break :o .{ null, 1 };
2568
2564
  } },
2565
+ .net_read => |o| return .{
2566
+ .net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
2567
+ error.Canceled => |e| return e,
2568
+ else => |e| e,
2569
+ },
2570
+ },
2569
2571
  }
2570
2572
  }
2571
2573
 
@@ -2621,6 +2623,14 @@ fn batchAwaitAsync(userdata: ?*anyopaque, b: *Io.Batch) Io.Cancelable!void {
2621
2623
  };
2622
2624
  poll_len += 1;
2623
2625
  },
2626
+ .net_read => |o| {
2627
+ poll_buffer[poll_len] = .{
2628
+ .fd = o.socket_handle,
2629
+ .events = posix.POLL.IN | posix.POLL.ERR,
2630
+ .revents = 0,
2631
+ };
2632
+ poll_len += 1;
2633
+ },
2624
2634
  }
2625
2635
  index = submission.node.next;
2626
2636
  }
@@ -2798,6 +2808,7 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout
2798
2808
  storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
2799
2809
  b.completed.tail = index;
2800
2810
  },
2811
+ .net_read => |o| try poll_storage.add(o.socket_handle, posix.POLL.IN | posix.POLL.ERR),
2801
2812
  }
2802
2813
  index = submission.node.next;
2803
2814
  }
@@ -2993,6 +3004,7 @@ fn batchApc(
2993
3004
  .file_write_streaming => .{ .file_write_streaming = ntWriteFileResult(iosb) },
2994
3005
  .device_io_control => .{ .device_io_control = iosb.* },
2995
3006
  .net_receive => unreachable,
3007
+ .net_read => unreachable,
2996
3008
  };
2997
3009
  storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
2998
3010
  },
@@ -3201,6 +3213,16 @@ fn batchDrainSubmittedWindows(t: *Threaded, b: *Io.Batch, concurrency: bool) (Io
3201
3213
  .net_receive = netReceiveWindows(t, o.socket_handle, o.message_buffer, o.data_buffer, o.flags),
3202
3214
  });
3203
3215
  },
3216
+ .net_read => |*o| {
3217
+ // TODO integrate with overlapped I/O or equivalent to avoid this error
3218
+ if (concurrency) return error.ConcurrencyUnavailable;
3219
+ batchCompleteBlockingWindows(b, operation_userdata, .{
3220
+ .net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
3221
+ error.Canceled => |e| return e,
3222
+ else => |e| e,
3223
+ },
3224
+ });
3225
+ },
3204
3226
  }
3205
3227
  index = submission.node.next;
3206
3228
  }
@@ -5345,7 +5367,7 @@ fn dirOpenDirHaiku(
5345
5367
  .NOMEM => return error.SystemResources,
5346
5368
  .NOTDIR => return error.NotDir,
5347
5369
  .PERM => return error.PermissionDenied,
5348
- .BUSY => return error.DeviceBusy,
5370
+ .BUSY => |err| return errnoBug(err),
5349
5371
  else => |err| return posix.unexpectedErrno(err),
5350
5372
  }
5351
5373
  },
@@ -5462,7 +5484,7 @@ fn dirReadLinux(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir
5462
5484
  }
5463
5485
  const syscall: Syscall = try .start();
5464
5486
  const n = while (true) {
5465
- const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
5487
+ const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
5466
5488
  switch (linux.errno(rc)) {
5467
5489
  .SUCCESS => {
5468
5490
  syscall.finish();
@@ -5791,10 +5813,119 @@ fn dirReadIllumos(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
5791
5813
  }
5792
5814
 
5793
5815
  fn dirReadHaiku(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
5794
- _ = userdata;
5795
- _ = dr;
5796
- _ = buffer;
5797
- @panic("TODO implement dirReadHaiku");
5816
+ const t: *Threaded = @ptrCast(@alignCast(userdata));
5817
+ _ = t;
5818
+ var buffer_index: usize = 0;
5819
+ while (buffer.len - buffer_index != 0) {
5820
+ if (dr.end - dr.index == 0) {
5821
+ // Refill the buffer, unless we've already created references to
5822
+ // buffered data.
5823
+ if (buffer_index != 0) break;
5824
+ if (dr.state == .reset) {
5825
+ const syscall: Syscall = try .start();
5826
+ while (true) {
5827
+ const rc = posix.system._kern_rewind_dir(dr.dir.handle);
5828
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5829
+ .SUCCESS => {
5830
+ syscall.finish();
5831
+ break;
5832
+ },
5833
+ .INTR => {
5834
+ try syscall.checkCancel();
5835
+ continue;
5836
+ },
5837
+ else => |e| {
5838
+ syscall.finish();
5839
+ switch (e) {
5840
+ else => |err| return posix.unexpectedErrno(err),
5841
+ }
5842
+ },
5843
+ }
5844
+ }
5845
+ dr.state = .reading;
5846
+ }
5847
+ const syscall: Syscall = try .start();
5848
+ const n: usize = while (true) {
5849
+ const rc = posix.system._kern_read_dir(dr.dir.handle, dr.buffer.ptr, dr.buffer.len, @truncate(dr.buffer.len / @sizeOf(posix.system.DirEnt)));
5850
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5851
+ .SUCCESS => {
5852
+ syscall.finish();
5853
+ break @intCast(rc);
5854
+ },
5855
+ .INTR => {
5856
+ try syscall.checkCancel();
5857
+ continue;
5858
+ },
5859
+ else => |e| {
5860
+ syscall.finish();
5861
+ switch (e) {
5862
+ else => |err| return posix.unexpectedErrno(err),
5863
+ }
5864
+ },
5865
+ }
5866
+ };
5867
+ if (n == 0) {
5868
+ dr.state = .finished;
5869
+ return 0;
5870
+ }
5871
+ dr.index = 0;
5872
+ // _kern_read_dir returns entry count, but Dir.Reader is designed for byte count
5873
+ dr.end = 0;
5874
+ var i: usize = 0;
5875
+ while (i < n) : (i += 1) {
5876
+ const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.end]));
5877
+ dr.end += entry.reclen;
5878
+ }
5879
+ }
5880
+ const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.index]));
5881
+ const next_index = dr.index + entry.reclen;
5882
+ dr.index = next_index;
5883
+
5884
+ const name = std.mem.sliceTo(@as([*:0]u8, @ptrCast(&entry.name)), 0);
5885
+ if (std.mem.eql(u8, name, ".") or std.mem.eql(u8, name, "..") or entry.ino == 0) continue;
5886
+
5887
+ // haiku dirent doesn't expose type, so we have to call stat to get it.
5888
+ var stat: std.c.Stat = undefined;
5889
+ {
5890
+ const syscall: Syscall = try .start();
5891
+ while (true) {
5892
+ const rc = posix.system._kern_read_stat(dr.dir.handle, name, false, &stat, @sizeOf(std.c.Stat));
5893
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5894
+ .SUCCESS => {
5895
+ syscall.finish();
5896
+ break;
5897
+ },
5898
+ .INTR => {
5899
+ try syscall.checkCancel();
5900
+ continue;
5901
+ },
5902
+ else => |e| {
5903
+ syscall.finish();
5904
+ switch (e) {
5905
+ else => |err| return posix.unexpectedErrno(err),
5906
+ }
5907
+ },
5908
+ }
5909
+ }
5910
+ }
5911
+
5912
+ const entry_kind: File.Kind = switch (stat.mode & posix.S.IFMT) {
5913
+ posix.S.IFBLK => .block_device,
5914
+ posix.S.IFCHR => .character_device,
5915
+ posix.S.IFDIR => .directory,
5916
+ posix.S.IFIFO => .named_pipe,
5917
+ posix.S.IFLNK => .sym_link,
5918
+ posix.S.IFREG => .file,
5919
+ else => .unknown,
5920
+ };
5921
+ buffer[buffer_index] = .{
5922
+ .name = name,
5923
+ .kind = entry_kind,
5924
+ .inode = entry.ino,
5925
+ };
5926
+ buffer_index += 1;
5927
+ }
5928
+ return buffer_index;
5798
5929
  }
5799
5930
 
5800
5931
  fn dirReadWindows(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
@@ -9812,7 +9943,10 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
9812
9943
  if (have_preadv) {
9813
9944
  const syscall: Syscall = try .start();
9814
9945
  while (true) {
9815
- const rc = preadv_sym(file.handle, dest.ptr, @intCast(dest.len), @bitCast(offset));
9946
+ const rc = if (native_os == .haiku)
9947
+ posix.system.readv_pos(file.handle, @bitCast(offset), dest.ptr, @intCast(dest.len))
9948
+ else
9949
+ preadv_sym(file.handle, dest.ptr, @intCast(dest.len), @bitCast(offset));
9816
9950
  switch (posix.errno(rc)) {
9817
9951
  .SUCCESS => {
9818
9952
  syscall.finish();
@@ -9846,7 +9980,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
9846
9980
 
9847
9981
  const syscall: Syscall = try .start();
9848
9982
  while (true) {
9849
- const rc = posix.pread(file.handle, dest[0].ptr, @intCast(dest[0].len), @bitCast(offset));
9983
+ const rc = pread_sym(file.handle, dest[0].base, @intCast(dest[0].len), @bitCast(offset));
9850
9984
  switch (posix.errno(rc)) {
9851
9985
  .SUCCESS => {
9852
9986
  syscall.finish();
@@ -10035,10 +10169,10 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
10035
10169
  if (posix.SEEK == void) return error.Unseekable;
10036
10170
 
10037
10171
  if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
10038
- var result: u64 = undefined;
10172
+ var result: i64 = undefined;
10039
10173
  const syscall: Syscall = try .start();
10040
10174
  while (true) {
10041
- switch (posix.errno(posix.system.llseek(file.handle, @bitCast(offset), &result, posix.SEEK.CUR))) {
10175
+ switch (posix.errno(posix.system.llseek(file.handle, offset, &result, posix.SEEK.CUR))) {
10042
10176
  .SUCCESS => {
10043
10177
  syscall.finish();
10044
10178
  return;
@@ -10149,8 +10283,8 @@ fn posixSeekTo(fd: posix.fd_t, offset: u64) File.SeekError!void {
10149
10283
  if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
10150
10284
  const syscall: Syscall = try .start();
10151
10285
  while (true) {
10152
- var result: u64 = undefined;
10153
- switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.SET))) {
10286
+ var result: i64 = undefined;
10287
+ switch (posix.errno(posix.system.llseek(fd, @bitCast(offset), &result, posix.SEEK.SET))) {
10154
10288
  .SUCCESS => {
10155
10289
  syscall.finish();
10156
10290
  return;
@@ -10550,7 +10684,10 @@ fn fileWritePositional(
10550
10684
 
10551
10685
  const syscall: Syscall = try .start();
10552
10686
  while (true) {
10553
- const rc = pwritev_sym(file.handle, &iovecs, @intCast(iovlen), @bitCast(offset));
10687
+ const rc = if (native_os == .haiku)
10688
+ posix.system.writev_pos(file.handle, @bitCast(offset), &iovecs, @intCast(iovlen))
10689
+ else
10690
+ pwritev_sym(file.handle, &iovecs, @intCast(iovlen), @bitCast(offset));
10554
10691
  switch (posix.errno(rc)) {
10555
10692
  .SUCCESS => {
10556
10693
  syscall.finish();
@@ -12549,11 +12686,14 @@ fn deferAcceptAfd(t: *Threaded, listen_handle: net.Socket.Handle, info: windows.
12549
12686
  }
12550
12687
  }
12551
12688
 
12552
- fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12689
+ fn netRead(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12553
12690
  if (!have_networking) return error.NetworkDown;
12554
- const t: *Threaded = @ptrCast(@alignCast(userdata));
12555
- _ = t;
12556
12691
 
12692
+ if (is_windows) return netReadWindows(socket_handle, data);
12693
+ return netReadPosix(socket_handle, data);
12694
+ }
12695
+
12696
+ fn netReadPosix(fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12557
12697
  var iovecs_buffer: [max_iovecs_len]posix.iovec = undefined;
12558
12698
  var i: usize = 0;
12559
12699
  for (data) |buf| {
@@ -12590,7 +12730,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12590
12730
  .NOMEM => return error.SystemResources,
12591
12731
  .NOTCONN => return error.SocketUnconnected,
12592
12732
  .CONNRESET => return error.ConnectionResetByPeer,
12593
- .TIMEDOUT => return error.Timeout,
12594
12733
  .NOTCAPABLE => return error.AccessDenied,
12595
12734
  else => |err| return posix.unexpectedErrno(err),
12596
12735
  }
@@ -12622,7 +12761,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12622
12761
  .NOMEM => return error.SystemResources,
12623
12762
  .NOTCONN => return error.SocketUnconnected,
12624
12763
  .CONNRESET => return error.ConnectionResetByPeer,
12625
- .TIMEDOUT => return error.Timeout,
12626
12764
  .PIPE => return error.SocketUnconnected,
12627
12765
  .NETDOWN => return error.NetworkDown,
12628
12766
  else => |err| return posix.unexpectedErrno(err),
@@ -12632,11 +12770,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12632
12770
  }
12633
12771
  }
12634
12772
 
12635
- fn netReadWindows(userdata: ?*anyopaque, socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12636
- if (!have_networking) return error.NetworkDown;
12637
- const t: *Threaded = @ptrCast(@alignCast(userdata));
12638
- _ = t;
12639
-
12773
+ fn netReadWindows(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12640
12774
  var iovecs: [max_iovecs_len]windows.AFD.WSABUF(.@"var") = undefined;
12641
12775
  var len: u32 = 0;
12642
12776
  for (data) |buf| {
@@ -14063,7 +14197,7 @@ pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode,
14063
14197
  .dgram => posix.SOCK.DGRAM,
14064
14198
  .seqpacket => posix.SOCK.SEQPACKET,
14065
14199
  .raw => posix.SOCK.RAW,
14066
- .rdm => posix.SOCK.RDM,
14200
+ .rdm => if (@hasDecl(posix.SOCK, "RDM")) posix.SOCK.RDM else return error.OptionUnsupported,
14067
14201
  },
14068
14202
  if (protocol) |p| @intFromEnum(p) else if (is_windows) switch (family) {
14069
14203
  posix.AF.UNIX => switch (mode) {
@@ -14455,7 +14589,7 @@ fn lookupDns(
14455
14589
  }
14456
14590
  }
14457
14591
  if (recv_err) |err| switch (err) {
14458
- error.Canceled => return error.Canceled,
14592
+ error.Canceled => |e| return e,
14459
14593
  error.Timeout => continue :send,
14460
14594
  else => continue,
14461
14595
  };
@@ -14592,13 +14726,13 @@ fn lookupHostsReader(
14592
14726
  const line = reader.takeDelimiterExclusive('\n') catch |err| switch (err) {
14593
14727
  error.StreamTooLong => {
14594
14728
  // Skip lines that are too long.
14595
- _ = reader.discardDelimiterInclusive('\n') catch |e| switch (e) {
14729
+ _ = reader.discardDelimiterInclusive('\n') catch |er| switch (er) {
14596
14730
  error.EndOfStream => break,
14597
- error.ReadFailed => return error.ReadFailed,
14731
+ error.ReadFailed => |e| return e,
14598
14732
  };
14599
14733
  continue;
14600
14734
  },
14601
- error.ReadFailed => return error.ReadFailed,
14735
+ error.ReadFailed => |e| return e,
14602
14736
  error.EndOfStream => break,
14603
14737
  };
14604
14738
  reader.toss(@min(1, reader.bufferedLen()));
@@ -15247,7 +15381,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
15247
15381
  const ru_ptr = if (child.request_resource_usage_statistics) &ru else null;
15248
15382
 
15249
15383
  if (have_wait4) {
15250
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15384
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15251
15385
  const syscall: Syscall = try .start();
15252
15386
  while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, ru_ptr))) {
15253
15387
  .SUCCESS => {
@@ -15290,7 +15424,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
15290
15424
  };
15291
15425
  }
15292
15426
 
15293
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15427
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15294
15428
  const syscall: Syscall = try .start();
15295
15429
  while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
15296
15430
  .SUCCESS => {
@@ -15332,7 +15466,7 @@ fn childKillPosix(child: *process.Child) !void {
15332
15466
  };
15333
15467
 
15334
15468
  if (have_wait4) {
15335
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15469
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15336
15470
  while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, null))) {
15337
15471
  .SUCCESS => return,
15338
15472
  .INTR => continue,
@@ -15352,7 +15486,7 @@ fn childKillPosix(child: *process.Child) !void {
15352
15486
  };
15353
15487
  }
15354
15488
 
15355
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15489
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15356
15490
  while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
15357
15491
  .SUCCESS => return,
15358
15492
  .INTR => continue,
package/std/Io/Uring.zig CHANGED
@@ -779,7 +779,6 @@ pub fn io(ev: *Evented) Io {
779
779
  .netConnectUnix = netConnectUnixUnavailable,
780
780
  .netSocketCreatePair = netSocketCreatePairUnavailable,
781
781
  .netSend = netSendUnavailable,
782
- .netRead = netReadUnavailable,
783
782
  .netWrite = netWriteUnavailable,
784
783
  .netWriteFile = netWriteFileUnavailable,
785
784
  .netClose = netClose,
@@ -2105,6 +2104,12 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
2105
2104
  };
2106
2105
  },
2107
2106
  },
2107
+ .net_read => |o| .{
2108
+ .net_read = r: {
2109
+ _ = o;
2110
+ break :r error.NetworkDown; // TODO
2111
+ },
2112
+ },
2108
2113
  };
2109
2114
  }
2110
2115
 
@@ -2392,6 +2397,10 @@ fn batchDrainSubmitted(
2392
2397
  _ = o;
2393
2398
  @panic("TODO implement batchDrainSubmitted for net_receive");
2394
2399
  },
2400
+ .net_read => |o| {
2401
+ _ = o;
2402
+ @panic("TODO implement batchDrainSubmitted for net_read");
2403
+ },
2395
2404
  })) |result| {
2396
2405
  switch (batch.completed.tail) {
2397
2406
  .none => batch.completed.head = index,
@@ -2493,6 +2502,7 @@ fn batchDrainReady(batch: *Io.Batch) Io.Timeout.Error!void {
2493
2502
  },
2494
2503
  .device_io_control => unreachable,
2495
2504
  .net_receive => @panic("TODO"),
2505
+ .net_read => @panic("TODO"),
2496
2506
  })) |result| {
2497
2507
  switch (batch.completed.tail) {
2498
2508
  .none => batch.completed.head = index,
@@ -3060,7 +3070,7 @@ fn dirRead(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Read
3060
3070
  }
3061
3071
  const n = while (true) {
3062
3072
  try sync.cancel_region.await(.nothing);
3063
- const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
3073
+ const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
3064
3074
  switch (linux.errno(rc)) {
3065
3075
  .SUCCESS => break rc,
3066
3076
  .INTR => {},
@@ -4948,7 +4958,7 @@ fn randomSecure(userdata: ?*anyopaque, buffer: []u8) Io.RandomSecureError!void {
4948
4958
  var cancel_region: CancelRegion = .init();
4949
4959
  defer cancel_region.deinit();
4950
4960
  ev.urandomReadAll(&cancel_region, buffer) catch |err| switch (err) {
4951
- error.Canceled => return error.Canceled,
4961
+ error.Canceled => |e| return e,
4952
4962
  else => return error.EntropyUnavailable,
4953
4963
  };
4954
4964
  }
@@ -5142,18 +5152,6 @@ fn netReceive(
5142
5152
  }
5143
5153
  }
5144
5154
 
5145
- fn netReadUnavailable(
5146
- userdata: ?*anyopaque,
5147
- fd: net.Socket.Handle,
5148
- data: [][]u8,
5149
- ) net.Stream.Reader.Error!usize {
5150
- const ev: *Evented = @ptrCast(@alignCast(userdata));
5151
- _ = ev;
5152
- _ = fd;
5153
- _ = data;
5154
- return error.NetworkDown;
5155
- }
5156
-
5157
5155
  fn netWriteUnavailable(
5158
5156
  userdata: ?*anyopaque,
5159
5157
  handle: net.Socket.Handle,
package/std/Io/Writer.zig CHANGED
@@ -551,64 +551,68 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void {
551
551
  while (index < bytes.len) index += try w.write(bytes[index..]);
552
552
  }
553
553
 
554
- /// Renders fmt string with args, calling `writer` with slices of bytes.
555
- /// If `writer` returns an error, the error is returned from `format` and
556
- /// `writer` is not called again.
554
+ /// Renders `fmt` string with `args`, calling `w` with slices of bytes.
557
555
  ///
558
- /// The format string must be comptime-known and may contain placeholders following
559
- /// this format:
560
- /// `{[argument][specifier]:[fill][alignment][width].[precision]}`
556
+ /// The format string must be comptime-known and may contain placeholders
557
+ /// following this format:
558
+ /// ```
559
+ /// {[argument][specifier]:[fill][alignment][width].[precision]}
560
+ /// ```
561
561
  ///
562
- /// Above, each word including its surrounding [ and ] is a parameter which you have to replace with something:
562
+ /// Above, each word including its surrounding [ and ] is a parameter to be replaced with:
563
563
  ///
564
- /// - *argument* is either the numeric index or the field name of the argument that should be inserted
565
- /// - when using a field name, you are required to enclose the field name (an identifier) in square
566
- /// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...}
567
- /// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below)
568
- /// - *fill* is a single byte which is used to pad formatted numbers.
569
- /// - *alignment* is one of the three bytes '<', '^', or '>' to make numbers
564
+ /// - **argument** is either the numeric index or the field name of the argument that should be inserted.
565
+ /// - When using a field name, the field name (an identifier) must be enclosed in square
566
+ /// brackets, e.g. `{[score]...}` as opposed to the numeric index form which can be written e.g. `{2...}`.
567
+ /// - **specifier** is a type-dependent formatting option that determines how a type should formatted (see below).
568
+ /// - **fill** is a single byte which is used to pad formatted numbers.
569
+ /// - **alignment** is one of the three bytes '<', '^', or '>' to make numbers
570
570
  /// left, center, or right-aligned, respectively.
571
571
  /// - Not all specifiers support alignment.
572
- /// - Alignment is not Unicode-aware; appropriate only when used with raw bytes or ASCII.
573
- /// - *width* is the total width of the field in bytes. This only applies to number formatting.
574
- /// - *precision* specifies how many decimals a formatted number should have.
572
+ /// - Alignment is not Unicode-aware; appropriate only when used with raw
573
+ /// bytes or ASCII.
574
+ /// - **width** is the total size of the field in bytes, only applicable to
575
+ /// number formatting.
576
+ /// - **precision** specifies how many decimals a formatted number should have.
575
577
  ///
576
- /// Note that most of the parameters are optional and may be omitted. Also you
577
- /// can leave out separators like `:` and `.` when all parameters after the
578
- /// separator are omitted.
578
+ /// Most of the parameters are optional and may be omitted. The separators (':'
579
+ /// and '.') may be omitted when all parameters afterwards are omitted.
579
580
  ///
580
- /// Only exception is the *fill* parameter. If a non-zero *fill* character is
581
- /// required at the same time as *width* is specified, one has to specify
582
- /// *alignment* as well, as otherwise the digit following `:` is interpreted as
583
- /// *width*, not *fill*.
581
+ /// The **fill** parameter is an exception. If a non-zero **fill** character is
582
+ /// required at the same time as **width** is specified, **alignment** is
583
+ /// required, otherwise the digit following ':' is interpreted as **width**.
584
584
  ///
585
- /// The *specifier* has several options for types:
586
- /// - `x` and `X`: output numeric value in hexadecimal notation, or string in hexadecimal bytes
585
+ /// **specifier** supports:
586
+ /// - `x` and `X`: numeric value in hexadecimal notation, or string in hexadecimal bytes
587
587
  /// - `s`:
588
588
  /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination
589
589
  /// - for slices of u8, print the entire slice as a string without zero-termination
590
590
  /// - `t`:
591
591
  /// - for enums and tagged unions: prints the tag name
592
592
  /// - for error sets: prints the error name
593
- /// - `b64`: output string as standard base64
594
- /// - `e`: output floating point value in scientific notation
595
- /// - `d`: output numeric value in decimal notation
596
- /// - `b`: output integer value in binary notation
597
- /// - `o`: output integer value in octal notation
598
- /// - `c`: output integer as an ASCII character. Integer type must have 8 bits at max.
599
- /// - `u`: output integer as an UTF-8 sequence. Integer type must have 21 bits at max.
600
- /// - `D`: output nanoseconds as duration
601
- /// - `B`: output bytes in SI units (decimal)
602
- /// - `Bi`: output bytes in IEC units (binary)
603
- /// - `?`: output optional value as either the unwrapped value, or `null`; may be followed by a format specifier for the underlying value.
604
- /// - `!`: output error union value as either the unwrapped value, or the formatted error value; may be followed by a format specifier for the underlying value.
605
- /// - `*`: output the address of the value instead of the value itself.
606
- /// - `any`: output a value of any type using its default format.
607
- /// - `f`: delegates to a method on the type named "format" with the signature `fn (*Writer, args: anytype) Writer.Error!void`.
593
+ /// - `b64`: string as standard base64
594
+ /// - `e`: floating point value in scientific notation
595
+ /// - `d`: numeric value in decimal notation
596
+ /// - `b`: integer value in binary notation
597
+ /// - `o`: integer value in octal notation
598
+ /// - `c`: integer as an ASCII character. Integer type must have 8 bits at max.
599
+ /// - `u`: integer as an UTF-8 sequence. Integer type must have 21 bits at max.
600
+ /// - `B`: bytes in SI units (decimal)
601
+ /// - `Bi`: bytes in IEC units (binary)
602
+ /// - `?`: optional value as either the unwrapped value, or `null`; may be
603
+ /// followed by a format specifier for the underlying value.
604
+ /// - `!`: error union value as either the unwrapped value, or the formatted
605
+ /// error value; may be followed by a format specifier for the underlying
606
+ /// value.
607
+ /// - `*`: the address of the value instead of the value itself.
608
+ /// - `any`: a value of any type using its default format.
609
+ /// - `f`: delegates to the `format` method of the type, passing `*Writer` and
610
+ /// expecting `Error!void` returned.
608
611
  ///
609
- /// A user type may be a `struct`, `vector`, `union` or `enum` type.
612
+ /// A user type may be a struct, vector, union or enum type.
610
613
  ///
611
- /// To print literal curly braces, escape them by writing them twice, e.g. `{{` or `}}`.
614
+ /// Literal curly braces can be escaped in the format string via doubling, e.g.
615
+ /// `{{` or `}}`.
612
616
  pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void {
613
617
  const ArgsType = @TypeOf(args);
614
618
  const args_type_info = @typeInfo(ArgsType);
package/std/Io/net.zig CHANGED
@@ -1245,6 +1245,15 @@ pub const Stream = struct {
1245
1245
 
1246
1246
  const max_iovecs_len = 8;
1247
1247
 
1248
+ /// This is a low-level API that calls the `Io` interface function directly.
1249
+ /// For a higher level API, see `reader`.
1250
+ pub fn read(s: *const Stream, io: Io, data: [][]u8) Reader.Error!usize {
1251
+ return (try io.operate(.{ .net_read = .{
1252
+ .socket_handle = s.socket.handle,
1253
+ .data = data,
1254
+ } })).net_read;
1255
+ }
1256
+
1248
1257
  pub fn close(s: *const Stream, io: Io) void {
1249
1258
  io.vtable.netClose(io.userdata, (&s.socket.handle)[0..1]);
1250
1259
  }
@@ -1259,16 +1268,7 @@ pub const Stream = struct {
1259
1268
  stream: Stream,
1260
1269
  err: ?Error,
1261
1270
 
1262
- pub const Error = error{
1263
- SystemResources,
1264
- ConnectionResetByPeer,
1265
- Timeout,
1266
- SocketUnconnected,
1267
- /// The file descriptor does not hold the required rights to read
1268
- /// from it.
1269
- AccessDenied,
1270
- NetworkDown,
1271
- } || Io.Cancelable || Io.UnexpectedError;
1271
+ pub const Error = Io.Operation.NetRead.Error || Io.Cancelable;
1272
1272
 
1273
1273
  pub fn init(stream: Stream, io: Io, buffer: []u8) Reader {
1274
1274
  return .{
@@ -1302,7 +1302,7 @@ pub const Stream = struct {
1302
1302
  const dest_n, const data_size = try io_r.writableVector(&iovecs_buffer, data);
1303
1303
  const dest = iovecs_buffer[0..dest_n];
1304
1304
  assert(dest[0].len > 0);
1305
- const n = io.vtable.netRead(io.userdata, r.stream.socket.handle, dest) catch |err| {
1305
+ const n = r.stream.read(io, dest) catch |err| {
1306
1306
  r.err = err;
1307
1307
  return error.ReadFailed;
1308
1308
  };