@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
package/std/Io.zig CHANGED
@@ -243,8 +243,6 @@ pub const VTable = struct {
243
243
  netConnectUnix: *const fn (?*anyopaque, *const net.UnixAddress) net.UnixAddress.ConnectError!net.Socket.Handle,
244
244
  netSocketCreatePair: *const fn (?*anyopaque, net.Socket.CreatePairOptions) net.Socket.CreatePairError![2]net.Socket,
245
245
  netSend: *const fn (?*anyopaque, net.Socket.Handle, []net.OutgoingMessage, net.SendFlags) struct { ?net.Socket.SendError, usize },
246
- /// Returns 0 on end of stream.
247
- netRead: *const fn (?*anyopaque, src: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize,
248
246
  netWrite: *const fn (?*anyopaque, dest: net.Socket.Handle, header: []const u8, data: []const []const u8, splat: usize) net.Stream.Writer.Error!usize,
249
247
  netWriteFile: *const fn (?*anyopaque, net.Socket.Handle, header: []const u8, *Io.File.Reader, Io.Limit) net.Stream.Writer.WriteFileError!usize,
250
248
  netClose: *const fn (?*anyopaque, handle: []const net.Socket.Handle) void,
@@ -261,6 +259,7 @@ pub const Operation = union(enum) {
261
259
  /// other systems this tag is unreachable.
262
260
  device_io_control: DeviceIoControl,
263
261
  net_receive: NetReceive,
262
+ net_read: NetRead,
264
263
 
265
264
  pub const Tag = @typeInfo(Operation).@"union".tag_type.?;
266
265
 
@@ -386,6 +385,23 @@ pub const Operation = union(enum) {
386
385
  pub const Result = struct { ?net.Socket.ReceiveError, usize };
387
386
  };
388
387
 
388
+ pub const NetRead = struct {
389
+ socket_handle: net.Socket.Handle,
390
+ data: [][]u8,
391
+
392
+ pub const Error = error{
393
+ SystemResources,
394
+ ConnectionResetByPeer,
395
+ SocketUnconnected,
396
+ /// The file descriptor does not hold the required rights to read
397
+ /// from it.
398
+ AccessDenied,
399
+ NetworkDown,
400
+ } || Io.UnexpectedError;
401
+
402
+ pub const Result = Error!usize;
403
+ };
404
+
389
405
  pub const Result = Result: {
390
406
  const operation_fields = @typeInfo(Operation).@"union".fields;
391
407
  var field_names: [operation_fields.len][]const u8 = undefined;
@@ -874,7 +890,7 @@ pub const Clock = enum {
874
890
  if (t.clock == clock) return t;
875
891
  const now_old = t.clock.now(io);
876
892
  const now_new = clock.now(io);
877
- const duration = now_old.durationTo(t);
893
+ const duration = now_old.durationTo(t.raw);
878
894
  return .{
879
895
  .clock = clock,
880
896
  .raw = now_new.addDuration(duration),
@@ -1665,20 +1681,29 @@ pub const Condition = struct {
1665
1681
  .epoch = .init(0),
1666
1682
  };
1667
1683
 
1684
+ /// Blocks until the condition is signaled or canceled.
1685
+ ///
1686
+ /// See also:
1687
+ /// * `waitUncancelable`
1688
+ /// * `waitTimeout`
1668
1689
  pub fn wait(cond: *Condition, io: Io, mutex: *Mutex) Cancelable!void {
1669
- try waitInner(cond, io, mutex, false);
1690
+ waitTimeout(cond, io, mutex, .none) catch |err| switch (err) {
1691
+ error.Timeout => unreachable,
1692
+ error.Canceled => |e| return e,
1693
+ };
1670
1694
  }
1671
1695
 
1672
- /// Same as `wait`, except does not introduce a cancelation point.
1696
+ pub const WaitTimeoutError = Cancelable || Timeout.Error;
1697
+
1698
+ /// Blocks until the condition is signaled, canceled, or the provided
1699
+ /// timeout expires.
1673
1700
  ///
1674
- /// For a description of cancelation and cancelation points, see `Future.cancel`.
1675
- pub fn waitUncancelable(cond: *Condition, io: Io, mutex: *Mutex) void {
1676
- waitInner(cond, io, mutex, true) catch |err| switch (err) {
1677
- error.Canceled => unreachable,
1678
- };
1679
- }
1701
+ /// See also:
1702
+ /// * `wait`
1703
+ /// * `waitUncancelable`
1704
+ pub fn waitTimeout(cond: *Condition, io: Io, mutex: *Mutex, timeout: Timeout) WaitTimeoutError!void {
1705
+ const deadline = timeout.toDeadline(io);
1680
1706
 
1681
- fn waitInner(cond: *Condition, io: Io, mutex: *Mutex, uncancelable: bool) Cancelable!void {
1682
1707
  var epoch = cond.epoch.load(.acquire); // `.acquire` to ensure ordered before state load
1683
1708
 
1684
1709
  {
@@ -1690,10 +1715,7 @@ pub const Condition = struct {
1690
1715
  defer mutex.lockUncancelable(io);
1691
1716
 
1692
1717
  while (true) {
1693
- const result = if (uncancelable)
1694
- io.futexWaitUncancelable(u32, &cond.epoch.raw, epoch)
1695
- else
1696
- io.futexWait(u32, &cond.epoch.raw, epoch);
1718
+ const result = io.futexWaitTimeout(u32, &cond.epoch.raw, epoch, deadline);
1697
1719
 
1698
1720
  epoch = cond.epoch.load(.acquire); // `.acquire` to ensure ordered before `state` laod
1699
1721
 
@@ -1713,13 +1735,62 @@ pub const Condition = struct {
1713
1735
  }
1714
1736
 
1715
1737
  // There are no more signals available; this was a spurious wakeup or an error. If it
1716
- // was an error, we will remove ourselves as a waiter and return that error. Otherwise,
1717
- // we'll loop back to the futex wait.
1738
+ // was an error, we will remove ourselves as a waiter and return that error. If a
1739
+ // timeout was specified and the deadline has passed, we remove ourselves as a waiter
1740
+ // and return `error.Timeout`. Otherwise, we'll loop back to the futex wait.
1718
1741
  result catch |err| {
1719
1742
  const prev_state = cond.state.fetchSub(.{ .waiters = 1, .signals = 0 }, .monotonic);
1720
1743
  assert(prev_state.waiters > 0); // underflow caused by illegal state
1721
1744
  return err;
1722
1745
  };
1746
+ switch (deadline) {
1747
+ .none => {},
1748
+ .deadline => |d| if (d.untilNow(io).raw.nanoseconds >= 0) {
1749
+ const prev_state = cond.state.fetchSub(.{ .waiters = 1, .signals = 0 }, .monotonic);
1750
+ assert(prev_state.waiters > 0); // underflow caused by illegal state
1751
+ return error.Timeout;
1752
+ },
1753
+ .duration => unreachable,
1754
+ }
1755
+ }
1756
+ }
1757
+
1758
+ /// Same as `wait`, except does not introduce a cancelation point.
1759
+ ///
1760
+ /// See `Future.cancel` for a description of cancelation points.
1761
+ pub fn waitUncancelable(cond: *Condition, io: Io, mutex: *Mutex) void {
1762
+ var epoch = cond.epoch.load(.acquire); // `.acquire` to ensure ordered before state load
1763
+
1764
+ {
1765
+ const prev_state = cond.state.fetchAdd(.{ .waiters = 1, .signals = 0 }, .monotonic);
1766
+ assert(prev_state.waiters < math.maxInt(u16)); // overflow caused by too many waiters
1767
+ }
1768
+
1769
+ mutex.unlock(io);
1770
+ defer mutex.lockUncancelable(io);
1771
+
1772
+ while (true) {
1773
+ io.futexWaitUncancelable(u32, &cond.epoch.raw, epoch);
1774
+
1775
+ epoch = cond.epoch.load(.acquire); // `.acquire` to ensure ordered before `state` laod
1776
+
1777
+ // Even on error, try to consume a pending signal first. Otherwise a race might
1778
+ // cause a signal to get stuck in the state with no corresponding waiter.
1779
+ {
1780
+ var prev_state = cond.state.load(.monotonic);
1781
+ while (prev_state.signals > 0) {
1782
+ prev_state = cond.state.cmpxchgWeak(prev_state, .{
1783
+ .waiters = prev_state.waiters - 1,
1784
+ .signals = prev_state.signals - 1,
1785
+ }, .acquire, .monotonic) orelse {
1786
+ // We successfully consumed a signal.
1787
+ return;
1788
+ };
1789
+ }
1790
+ }
1791
+
1792
+ // There are no more signals available; this was a spurious wakeup,
1793
+ // so we'll loop back to the futex wait.
1723
1794
  }
1724
1795
  }
1725
1796
 
@@ -2626,7 +2697,6 @@ pub const failing: std.Io = .{
2626
2697
  .netConnectUnix = failingNetConnectUnix,
2627
2698
  .netSocketCreatePair = failingNetSocketCreatePair,
2628
2699
  .netSend = failingNetSend,
2629
- .netRead = failingNetRead,
2630
2700
  .netWrite = failingNetWrite,
2631
2701
  .netWriteFile = failingNetWriteFile,
2632
2702
  .netClose = unreachableNetClose,
@@ -2774,6 +2844,7 @@ pub fn failingOperate(userdata: ?*anyopaque, operation: Operation) Cancelable!Op
2774
2844
  .file_write_streaming => .{ .file_write_streaming = error.InputOutput },
2775
2845
  .device_io_control => unreachable,
2776
2846
  .net_receive => .{ .net_receive = .{ error.NetworkDown, 0 } },
2847
+ .net_read => .{ .net_read = error.NetworkDown },
2777
2848
  };
2778
2849
  }
2779
2850
 
@@ -3377,13 +3448,6 @@ pub fn failingNetSend(userdata: ?*anyopaque, handle: net.Socket.Handle, messages
3377
3448
  return .{ error.NetworkDown, 0 };
3378
3449
  }
3379
3450
 
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
3451
  pub fn failingNetWrite(userdata: ?*anyopaque, dest: net.Socket.Handle, header: []const u8, data: []const []const u8, splat: usize) net.Stream.Writer.Error!usize {
3388
3452
  _ = userdata;
3389
3453
  _ = dest;
@@ -146,7 +146,7 @@ fn parseNum(text: []const u8) error{ InvalidVersion, Overflow }!usize {
146
146
 
147
147
  return std.fmt.parseUnsigned(usize, text, 10) catch |err| switch (err) {
148
148
  error.InvalidCharacter => return error.InvalidVersion,
149
- error.Overflow => return error.Overflow,
149
+ error.Overflow => |e| return e,
150
150
  };
151
151
  }
152
152
 
@@ -253,7 +253,7 @@ pub fn parse(args: ParseOptions) !Query {
253
253
  } else if (abi.isAndroid()) {
254
254
  result.android_api_level = std.fmt.parseUnsigned(u32, abi_ver_text, 10) catch |err| switch (err) {
255
255
  error.InvalidCharacter => return error.InvalidVersion,
256
- error.Overflow => return error.Overflow,
256
+ error.Overflow => |e| return e,
257
257
  };
258
258
  } else {
259
259
  return error.InvalidAbiVersion;
@@ -346,7 +346,7 @@ pub fn parseVersion(ver: []const u8) error{ InvalidVersion, Overflow }!SemanticV
346
346
  fn parseVersionComponentInner(component: []const u8) error{ InvalidVersion, Overflow }!usize {
347
347
  return std.fmt.parseUnsigned(usize, component, 10) catch |err| switch (err) {
348
348
  error.InvalidCharacter => return error.InvalidVersion,
349
- error.Overflow => return error.Overflow,
349
+ error.Overflow => |e| return e,
350
350
  };
351
351
  }
352
352
  }).parseVersionComponentInner;
package/std/Target.zig CHANGED
@@ -68,6 +68,8 @@ pub const Os = struct {
68
68
  opengl,
69
69
  vulkan,
70
70
 
71
+ tios,
72
+
71
73
  // LLVM tags deliberately omitted:
72
74
  // - bridgeos
73
75
  // - cheriotrtos
@@ -207,6 +209,8 @@ pub const Os = struct {
207
209
  .opencl,
208
210
  .opengl,
209
211
  .vulkan,
212
+
213
+ .tios,
210
214
  => .semver,
211
215
 
212
216
  .hurd => .hurd,
@@ -670,6 +674,12 @@ pub const Os = struct {
670
674
  .max = .{ .major = 4, .minor = 6, .patch = 0 },
671
675
  },
672
676
  },
677
+ .tios => .{
678
+ .semver = .{
679
+ .min = .{ .major = 5, .minor = 0, .patch = 0 },
680
+ .max = .{ .major = 5, .minor = 8, .patch = 4 },
681
+ },
682
+ },
673
683
  .vulkan => .{
674
684
  .semver = .{
675
685
  .min = .{ .major = 1, .minor = 2, .patch = 0 },
@@ -758,6 +768,7 @@ pub const wasm = @import("Target/wasm.zig");
758
768
  pub const x86 = @import("Target/x86.zig");
759
769
  pub const xcore = @import("Target/xcore.zig");
760
770
  pub const xtensa = @import("Target/xtensa.zig");
771
+ pub const z80 = @import("Target/generic.zig");
761
772
 
762
773
  pub const Abi = enum {
763
774
  none,
@@ -942,6 +953,7 @@ pub const Abi = enum {
942
953
  .opencl,
943
954
  .opengl,
944
955
  .vulkan,
956
+ .tios,
945
957
  => .none,
946
958
  };
947
959
  }
@@ -1068,6 +1080,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
1068
1080
  .avr => .AVR,
1069
1081
  .bpfeb, .bpfel => .BPF,
1070
1082
  .csky => .CSKY,
1083
+ .ez80 => .Z80,
1071
1084
  .hexagon => .QDSP6,
1072
1085
  .hppa, .hppa64 => .PARISC,
1073
1086
  .kalimba => .CSR_KALIMBA,
@@ -1130,6 +1143,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
1130
1143
  .bpfeb,
1131
1144
  .bpfel,
1132
1145
  .csky,
1146
+ .ez80,
1133
1147
  .hexagon,
1134
1148
  .hppa,
1135
1149
  .hppa64,
@@ -1336,6 +1350,7 @@ pub const Cpu = struct {
1336
1350
  bpfeb,
1337
1351
  bpfel,
1338
1352
  csky,
1353
+ ez80,
1339
1354
  hexagon,
1340
1355
  hppa,
1341
1356
  hppa64,
@@ -1437,6 +1452,7 @@ pub const Cpu = struct {
1437
1452
  x86,
1438
1453
  xcore,
1439
1454
  xtensa,
1455
+ z80,
1440
1456
  };
1441
1457
 
1442
1458
  pub inline fn family(arch: Arch) Family {
@@ -1449,6 +1465,7 @@ pub const Cpu = struct {
1449
1465
  .avr => .avr,
1450
1466
  .bpfeb, .bpfel => .bpf,
1451
1467
  .csky => .csky,
1468
+ .ez80 => .z80,
1452
1469
  .hexagon => .hexagon,
1453
1470
  .hppa, .hppa64 => .hppa,
1454
1471
  .kalimba => .kalimba,
@@ -1678,6 +1695,7 @@ pub const Cpu = struct {
1678
1695
  .x86_64,
1679
1696
  .xcore,
1680
1697
  .xtensa,
1698
+ .ez80,
1681
1699
  => .little,
1682
1700
 
1683
1701
  .aarch64_be,
@@ -1948,6 +1966,10 @@ pub const Cpu = struct {
1948
1966
  .spirv_fragment,
1949
1967
  .spirv_vertex,
1950
1968
  => &.{ .spirv32, .spirv64 },
1969
+
1970
+ .ez80_cet,
1971
+ .ez80_tiflags,
1972
+ => &.{.ez80},
1951
1973
  };
1952
1974
  }
1953
1975
  };
@@ -2236,6 +2258,7 @@ pub fn requiresLibC(target: *const Target) bool {
2236
2258
  .plan9,
2237
2259
  .other,
2238
2260
  .@"3ds",
2261
+ .tios,
2239
2262
  => false,
2240
2263
  };
2241
2264
  }
@@ -2398,6 +2421,8 @@ pub const DynamicLinker = struct {
2398
2421
  .ps5,
2399
2422
  .psp,
2400
2423
  .vita,
2424
+
2425
+ .tios,
2401
2426
  => .none,
2402
2427
  };
2403
2428
  }
@@ -2815,6 +2840,8 @@ pub const DynamicLinker = struct {
2815
2840
  .opencl,
2816
2841
  .opengl,
2817
2842
  .vulkan,
2843
+
2844
+ .tios,
2818
2845
  => none,
2819
2846
 
2820
2847
  // TODO go over each item in this list and either move it to the above list, or
@@ -2849,6 +2876,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
2849
2876
  .x86_16,
2850
2877
  => 16,
2851
2878
 
2879
+ .ez80,
2880
+ => 24,
2881
+
2852
2882
  .arc,
2853
2883
  .arceb,
2854
2884
  .arm,
@@ -2917,6 +2947,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
2917
2947
  pub fn stackAlignment(target: *const Target) u16 {
2918
2948
  // Overrides for when the stack alignment is not equal to the pointer width.
2919
2949
  switch (target.cpu.arch) {
2950
+ .ez80,
2951
+ => return 1,
2920
2952
  .m68k,
2921
2953
  => return 2,
2922
2954
  .amdgcn,
@@ -2997,6 +3029,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
2997
3029
  .arc,
2998
3030
  .arceb,
2999
3031
  .csky,
3032
+ .ez80,
3000
3033
  .hexagon,
3001
3034
  .msp430,
3002
3035
  .powerpc,
@@ -3049,8 +3082,6 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 {
3049
3082
  => @divExact(cTypeBitSize(t, c_type), 8),
3050
3083
 
3051
3084
  .longdouble => switch (cTypeBitSize(t, c_type)) {
3052
- 16 => 2,
3053
- 32 => 4,
3054
3085
  64 => 8,
3055
3086
  80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))),
3056
3087
  128 => 16,
@@ -3364,6 +3395,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3364
3395
  .long, .ulong => return 64,
3365
3396
  .longlong, .ulonglong, .double, .longdouble => return 64,
3366
3397
  },
3398
+ .tios => switch (c_type) {
3399
+ .char => return 8,
3400
+ .short, .ushort => return 16,
3401
+ .int, .uint => return 24,
3402
+ .long, .ulong, .float, .double => return 32,
3403
+ .longlong, .ulonglong, .longdouble => return 64,
3404
+ },
3367
3405
 
3368
3406
  .ps3,
3369
3407
  .contiki,
@@ -3376,7 +3414,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3376
3414
  pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
3377
3415
  // Overrides for unusual alignments
3378
3416
  switch (target.cpu.arch) {
3379
- .avr => return 1,
3417
+ .avr, .ez80 => return 1,
3380
3418
  .x86 => switch (target.os.tag) {
3381
3419
  .windows, .uefi => switch (c_type) {
3382
3420
  .longlong, .ulonglong, .double => return 8,
@@ -3406,6 +3444,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
3406
3444
  return @min(
3407
3445
  std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
3408
3446
  @as(u16, switch (target.cpu.arch) {
3447
+ .ez80 => 1,
3448
+
3409
3449
  .msp430,
3410
3450
  .x86_16,
3411
3451
  => 2,
@@ -3484,7 +3524,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3484
3524
  .longdouble => return 4,
3485
3525
  else => {},
3486
3526
  },
3487
- .avr => return 1,
3527
+ .avr, .ez80 => return 1,
3488
3528
  .x86 => switch (target.os.tag) {
3489
3529
  .windows, .uefi => switch (c_type) {
3490
3530
  .longdouble => switch (target.abi) {
@@ -3516,6 +3556,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3516
3556
  return @min(
3517
3557
  std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
3518
3558
  @as(u16, switch (target.cpu.arch) {
3559
+ .ez80 => 1,
3560
+
3519
3561
  .x86_16, .msp430 => 2,
3520
3562
 
3521
3563
  .arc,
@@ -3587,7 +3629,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3587
3629
 
3588
3630
  pub fn cMaxIntAlignment(target: *const Target) u16 {
3589
3631
  return switch (target.cpu.arch) {
3590
- .avr => 1,
3632
+ .avr,
3633
+ .ez80,
3634
+ => 1,
3591
3635
 
3592
3636
  .msp430, .x86_16 => 2,
3593
3637
 
@@ -3726,6 +3770,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
3726
3770
  .amdgcn => .{ .amdgcn_device = .{} },
3727
3771
  .nvptx, .nvptx64 => .nvptx_device,
3728
3772
  .spirv32, .spirv64 => .spirv_device,
3773
+ .ez80 => .ez80_cet,
3729
3774
  };
3730
3775
  }
3731
3776
 
@@ -280,8 +280,7 @@ pub fn Custom(
280
280
  if (it.index >= it.len) return null;
281
281
  const result = Entry{
282
282
  .key_ptr = &it.keys[it.index],
283
- // workaround for #6974
284
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &it.values[it.index],
283
+ .value_ptr = &it.values[it.index],
285
284
  };
286
285
  it.index += 1;
287
286
  return result;
@@ -323,8 +322,7 @@ pub fn Custom(
323
322
  const slice = self.entries.slice();
324
323
  return GetOrPutResult{
325
324
  .key_ptr = &slice.items(.key)[index],
326
- // workaround for #6974
327
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
325
+ .value_ptr = &slice.items(.value)[index],
328
326
  .found_existing = true,
329
327
  .index = index,
330
328
  };
@@ -369,8 +367,7 @@ pub fn Custom(
369
367
  if (hashes_array[i] == h and checkedEql(ctx, key, item_key.*, i)) {
370
368
  return GetOrPutResult{
371
369
  .key_ptr = item_key,
372
- // workaround for #6974
373
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[i],
370
+ .value_ptr = &slice.items(.value)[i],
374
371
  .found_existing = true,
375
372
  .index = i,
376
373
  };
@@ -383,8 +380,7 @@ pub fn Custom(
383
380
 
384
381
  return GetOrPutResult{
385
382
  .key_ptr = &keys_array.ptr[index],
386
- // workaround for #6974
387
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value).ptr[index],
383
+ .value_ptr = &slice.items(.value).ptr[index],
388
384
  .found_existing = false,
389
385
  .index = index,
390
386
  };
@@ -569,8 +565,7 @@ pub fn Custom(
569
565
  const slice = self.entries.slice();
570
566
  return Entry{
571
567
  .key_ptr = &slice.items(.key)[index],
572
- // workaround for #6974
573
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
568
+ .value_ptr = &slice.items(.value)[index],
574
569
  };
575
570
  }
576
571
 
@@ -634,8 +629,7 @@ pub fn Custom(
634
629
  }
635
630
  pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {
636
631
  const index = self.getIndexAdapted(key, ctx) orelse return null;
637
- // workaround for #6974
638
- return if (@sizeOf(*V) == 0) @as(*V, undefined) else &self.values()[index];
632
+ return &self.values()[index];
639
633
  }
640
634
 
641
635
  /// Find the actual key associated with an adapted key
@@ -1314,8 +1308,7 @@ pub fn Custom(
1314
1308
  return .{
1315
1309
  .found_existing = false,
1316
1310
  .key_ptr = &keys_array.ptr[new_index],
1317
- // workaround for #6974
1318
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1311
+ .value_ptr = &values_array.ptr[new_index],
1319
1312
  .index = new_index,
1320
1313
  };
1321
1314
  }
@@ -1328,8 +1321,7 @@ pub fn Custom(
1328
1321
  return .{
1329
1322
  .found_existing = true,
1330
1323
  .key_ptr = &keys_array[slot_data.entry_index],
1331
- // workaround for #6974
1332
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array[slot_data.entry_index],
1324
+ .value_ptr = &values_array[slot_data.entry_index],
1333
1325
  .index = slot_data.entry_index,
1334
1326
  };
1335
1327
  }
@@ -1370,8 +1362,7 @@ pub fn Custom(
1370
1362
  return .{
1371
1363
  .found_existing = false,
1372
1364
  .key_ptr = &keys_array.ptr[new_index],
1373
- // workaround for #6974
1374
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1365
+ .value_ptr = &values_array.ptr[new_index],
1375
1366
  .index = new_index,
1376
1367
  };
1377
1368
  }
package/std/builtin.zig CHANGED
@@ -341,6 +341,10 @@ pub const CallingConvention = union(enum(u8)) {
341
341
  spirv_fragment,
342
342
  spirv_vertex,
343
343
 
344
+ // Calling conventions for the `ez80` architecture.
345
+ ez80_cet,
346
+ ez80_tiflags,
347
+
344
348
  /// Options shared across most calling conventions.
345
349
  pub const CommonOptions = struct {
346
350
  /// The boundary the stack is aligned to when the function is called.
package/std/c/haiku.zig CHANGED
@@ -6,6 +6,7 @@ const iovec = std.posix.iovec;
6
6
  const iovec_const = std.posix.iovec_const;
7
7
  const socklen_t = std.c.socklen_t;
8
8
  const fd_t = std.c.fd_t;
9
+ const off_t = std.c.off_t;
9
10
  const PATH_MAX = std.c.PATH_MAX;
10
11
  const uid_t = std.c.uid_t;
11
12
  const gid_t = std.c.gid_t;
@@ -28,6 +29,8 @@ pub extern "root" fn _kern_open_dir(fd: fd_t, path: [*:0]const u8) fd_t;
28
29
  pub extern "root" fn _kern_read_dir(fd: fd_t, buffer: [*]u8, bufferSize: usize, maxCount: u32) isize;
29
30
  pub extern "root" fn _kern_rewind_dir(fd: fd_t) status_t;
30
31
  pub extern "root" fn _kern_read_stat(fd: fd_t, path: [*:0]const u8, traverseLink: bool, stat: *std.c.Stat, statSize: usize) status_t;
32
+ pub extern "root" fn readv_pos(fd: fd_t, pos: off_t, vec: [*]const std.c.iovec, count: i32) isize;
33
+ pub extern "root" fn writev_pos(fd: fd_t, pos: off_t, vec: [*]const std.c.iovec_const, count: i32) isize;
31
34
 
32
35
  pub const area_info = extern struct {
33
36
  area: u32,
@@ -53,9 +53,7 @@ pub extern "c" fn profiling_enable(pid: pid_t, event_mask: PERF_EVENT) c_int;
53
53
  pub extern "c" fn profiling_disable(pid: pid_t) c_int;
54
54
  pub extern "c" fn profiling_free_buffer(pid: pid_t) c_int;
55
55
 
56
- pub extern "c" fn futex(userspace_address: *u32, futex_op: c_int, value: u32, timeout: *const timespec, userspace_address2: *u32, value3: u32) c_int;
57
- pub extern "c" fn futex_wait(userspace_address: *u32, value: u32, abstime: *const timespec, clockid: clockid_t, process_shared: c_int) c_int;
58
- pub extern "c" fn futex_wake(userspace_address: *u32, count: u32, process_shared: c_int) c_int;
56
+ pub extern "c" fn futex(userspace_address: *u32, futex_op: c_int, value: u32, timeout: ?*const timespec, userspace_address2: ?*u32, value3: u32) c_int;
59
57
 
60
58
  pub extern "c" fn purge(mode: c_int) c_int;
61
59
 
@@ -66,9 +64,6 @@ pub extern "c" fn get_stack_bounds(user_stack_base: *usize, user_stack_size: *us
66
64
 
67
65
  pub extern "c" fn anon_create(size: usize, options: O) c_int;
68
66
 
69
- pub extern "c" fn serenity_readlink(path: [*]const u8, path_length: usize, buffer: [*]u8, buffer_size: usize) c_int;
70
- pub extern "c" fn serenity_open(path: [*]const u8, path_length: usize, options: c_int, ...) c_int;
71
-
72
67
  pub extern "c" fn getkeymap(name_buffer: [*]u8, name_buffer_size: usize, map: [*]u32, shift_map: [*]u32, alt_map: [*]u32, altgr_map: [*]u32, shift_altgr_map: [*]u32) c_int;
73
68
  pub extern "c" fn setkeymap(name: [*]const u8, map: [*]const u32, shift_map: [*]const u32, alt_map: [*]const u32, altgr_map: [*]const u32, shift_altgr_map: [*]const u32) c_int;
74
69