@zigc/lib 0.16.0 → 0.17.0-dev.131

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 (155) 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/musl/arch/mipsn32/syscall_arch.h +35 -32
  52. package/package.json +1 -1
  53. package/std/Build/Cache.zig +6 -6
  54. package/std/Build/Step/Compile.zig +0 -1
  55. package/std/Build/Step/Run.zig +2 -2
  56. package/std/Build/Step.zig +2 -4
  57. package/std/Build/WebServer.zig +2 -2
  58. package/std/Build.zig +0 -3
  59. package/std/Io/Dir.zig +7 -2
  60. package/std/Io/Dispatch.zig +3 -13
  61. package/std/Io/File/Writer.zig +8 -6
  62. package/std/Io/Reader.zig +8 -9
  63. package/std/Io/Semaphore.zig +112 -17
  64. package/std/Io/Terminal.zig +1 -1
  65. package/std/Io/Threaded.zig +171 -37
  66. package/std/Io/Uring.zig +13 -15
  67. package/std/Io/Writer.zig +46 -42
  68. package/std/Io/net.zig +11 -11
  69. package/std/Io.zig +90 -26
  70. package/std/SemanticVersion.zig +1 -1
  71. package/std/Target/Query.zig +2 -2
  72. package/std/Target.zig +50 -5
  73. package/std/array_hash_map.zig +9 -18
  74. package/std/builtin.zig +4 -0
  75. package/std/c/haiku.zig +3 -0
  76. package/std/c/serenity.zig +1 -6
  77. package/std/c.zig +89 -7
  78. package/std/compress/flate/Decompress.zig +2 -3
  79. package/std/compress/zstd/Decompress.zig +2 -4
  80. package/std/crypto/Certificate.zig +13 -1
  81. package/std/crypto/ascon.zig +75 -33
  82. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  83. package/std/crypto/codecs/base64_hex_ct.zig +2 -4
  84. package/std/crypto/ml_kem.zig +2 -9
  85. package/std/crypto/tls/Client.zig +79 -4
  86. package/std/crypto/tls.zig +1 -1
  87. package/std/crypto.zig +1 -0
  88. package/std/debug/Pdb.zig +1 -1
  89. package/std/debug.zig +4 -3
  90. package/std/fmt.zig +8 -3
  91. package/std/fs/path.zig +6 -4
  92. package/std/heap/BufferFirstAllocator.zig +165 -0
  93. package/std/heap.zig +2 -126
  94. package/std/http/Client.zig +21 -24
  95. package/std/http.zig +3 -4
  96. package/std/json/Scanner.zig +2 -2
  97. package/std/os/emscripten.zig +1 -1
  98. package/std/os/linux/IoUring.zig +2 -0
  99. package/std/os/linux/aarch64.zig +41 -12
  100. package/std/os/linux/arc.zig +173 -0
  101. package/std/os/linux/arm.zig +41 -12
  102. package/std/os/linux/hexagon.zig +33 -11
  103. package/std/os/linux/loongarch32.zig +41 -13
  104. package/std/os/linux/loongarch64.zig +41 -12
  105. package/std/os/linux/m68k.zig +41 -13
  106. package/std/os/linux/mips.zig +67 -36
  107. package/std/os/linux/mips64.zig +60 -29
  108. package/std/os/linux/mipsn32.zig +60 -29
  109. package/std/os/linux/or1k.zig +41 -12
  110. package/std/os/linux/powerpc.zig +41 -12
  111. package/std/os/linux/powerpc64.zig +41 -12
  112. package/std/os/linux/riscv32.zig +41 -12
  113. package/std/os/linux/riscv64.zig +41 -12
  114. package/std/os/linux/s390x.zig +44 -7
  115. package/std/os/linux/sparc64.zig +83 -52
  116. package/std/os/linux/thumb.zig +52 -36
  117. package/std/os/linux/x32.zig +41 -12
  118. package/std/os/linux/x86.zig +42 -13
  119. package/std/os/linux/x86_64.zig +41 -12
  120. package/std/os/linux.zig +412 -436
  121. package/std/os/uefi/tables/boot_services.zig +9 -8
  122. package/std/os.zig +41 -0
  123. package/std/process.zig +1 -1
  124. package/std/sort.zig +3 -3
  125. package/std/zig/Ast/Render.zig +3 -3
  126. package/std/zig/AstGen.zig +44 -98
  127. package/std/zig/AstRlAnnotate.zig +0 -11
  128. package/std/zig/BuiltinFn.zig +0 -32
  129. package/std/zig/LibCInstallation.zig +4 -3
  130. package/std/zig/Parse.zig +7 -7
  131. package/std/zig/WindowsSdk.zig +13 -13
  132. package/std/zig/Zir.zig +50 -63
  133. package/std/zig/ZonGen.zig +6 -5
  134. package/std/zig/llvm/Builder.zig +12 -12
  135. package/std/zig.zig +1 -10
  136. package/std/zip.zig +5 -5
  137. package/zig.h +340 -1
  138. package/libc/mingw/math/fdiml.c +0 -24
  139. package/libc/mingw/winpthreads/spinlock.c +0 -82
  140. package/libc/musl/src/linux/tee.c +0 -8
  141. package/libc/musl/src/math/fdimf.c +0 -10
  142. package/libc/musl/src/math/fdiml.c +0 -18
  143. package/libc/musl/src/string/strdup.c +0 -10
  144. package/libc/musl/src/string/strndup.c +0 -12
  145. package/libc/musl/src/string/wcsdup.c +0 -10
  146. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  147. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  148. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  149. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  150. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  151. package/libc/musl/src/unistd/dup2.c +0 -20
  152. package/libc/musl/src/unistd/dup3.c +0 -26
  153. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  154. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  155. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
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
  };
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