@zigc/lib 0.16.0-test.1 → 0.16.0

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 (241) hide show
  1. package/LICENSE +19 -0
  2. package/c/math.zig +135 -35
  3. package/c/stropts.zig +17 -0
  4. package/c.zig +1 -0
  5. package/compiler/aro/aro/Attribute/names.zig +604 -589
  6. package/compiler/aro/aro/Attribute.zig +202 -116
  7. package/compiler/aro/aro/Builtins/common.zig +874 -863
  8. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  9. package/compiler/aro/aro/Builtins.zig +0 -1
  10. package/compiler/aro/aro/CodeGen.zig +3 -1
  11. package/compiler/aro/aro/Compilation.zig +120 -97
  12. package/compiler/aro/aro/Diagnostics.zig +21 -17
  13. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  14. package/compiler/aro/aro/Driver.zig +124 -50
  15. package/compiler/aro/aro/LangOpts.zig +12 -2
  16. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  17. package/compiler/aro/aro/Parser.zig +336 -142
  18. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  19. package/compiler/aro/aro/Preprocessor.zig +127 -56
  20. package/compiler/aro/aro/Target.zig +17 -12
  21. package/compiler/aro/aro/Tokenizer.zig +31 -14
  22. package/compiler/aro/aro/Toolchain.zig +4 -7
  23. package/compiler/aro/aro/Tree.zig +178 -148
  24. package/compiler/aro/aro/TypeStore.zig +82 -24
  25. package/compiler/aro/aro/Value.zig +13 -17
  26. package/compiler/aro/aro/features.zig +1 -0
  27. package/compiler/aro/aro/pragmas/once.zig +0 -1
  28. package/compiler/aro/aro/record_layout.zig +3 -3
  29. package/compiler/aro/assembly_backend/x86_64.zig +3 -4
  30. package/compiler/aro/backend/Assembly.zig +1 -2
  31. package/compiler/aro/backend/Interner.zig +2 -2
  32. package/compiler/aro/backend/Ir.zig +100 -92
  33. package/compiler/aro/include/ptrcheck.h +49 -0
  34. package/compiler/aro/main.zig +26 -10
  35. package/compiler/build_runner.zig +1 -0
  36. package/compiler/objdump.zig +93 -0
  37. package/compiler/reduce.zig +5 -1
  38. package/compiler/resinator/compile.zig +2 -2
  39. package/compiler/resinator/main.zig +7 -1
  40. package/compiler/resinator/preprocess.zig +1 -3
  41. package/compiler/std-docs.zig +8 -1
  42. package/compiler/test_runner.zig +193 -61
  43. package/compiler/translate-c/MacroTranslator.zig +80 -11
  44. package/compiler/translate-c/PatternList.zig +1 -9
  45. package/compiler/translate-c/Scope.zig +43 -6
  46. package/compiler/translate-c/Translator.zig +364 -126
  47. package/compiler/translate-c/ast.zig +19 -11
  48. package/compiler/translate-c/main.zig +75 -16
  49. package/compiler_rt/cos.zig +141 -52
  50. package/compiler_rt/limb64.zig +266 -0
  51. package/compiler_rt/long_double.zig +37 -0
  52. package/compiler_rt/mulo.zig +6 -1
  53. package/compiler_rt/rem_pio2l.zig +173 -0
  54. package/compiler_rt/sin.zig +140 -55
  55. package/compiler_rt/sincos.zig +279 -72
  56. package/compiler_rt/tan.zig +118 -47
  57. package/compiler_rt/trig.zig +256 -6
  58. package/compiler_rt.zig +2 -0
  59. package/fuzzer.zig +855 -307
  60. package/libc/musl/src/math/pow.c +343 -0
  61. package/package.json +1 -1
  62. package/std/Build/Fuzz.zig +6 -19
  63. package/std/Build/Module.zig +1 -1
  64. package/std/Build/Step/CheckObject.zig +3 -3
  65. package/std/Build/Step/Compile.zig +18 -0
  66. package/std/Build/Step/ConfigHeader.zig +49 -33
  67. package/std/Build/Step/InstallArtifact.zig +18 -0
  68. package/std/Build/Step/Run.zig +536 -87
  69. package/std/Build/Step/TranslateC.zig +0 -6
  70. package/std/Build/Step.zig +8 -15
  71. package/std/Build/WebServer.zig +29 -17
  72. package/std/Build/abi.zig +47 -11
  73. package/std/Build.zig +17 -14
  74. package/std/Io/Dispatch.zig +2 -0
  75. package/std/Io/File/Reader.zig +3 -1
  76. package/std/Io/File.zig +1 -0
  77. package/std/Io/Kqueue.zig +2 -2
  78. package/std/Io/Threaded.zig +181 -143
  79. package/std/Io/Uring.zig +2 -1
  80. package/std/Io.zig +970 -2
  81. package/std/Target.zig +3 -2
  82. package/std/Thread.zig +8 -3
  83. package/std/array_hash_map.zig +96 -555
  84. package/std/array_list.zig +22 -31
  85. package/std/bit_set.zig +22 -6
  86. package/std/builtin/assembly.zig +68 -0
  87. package/std/c.zig +17 -17
  88. package/std/compress/flate/Compress.zig +3 -3
  89. package/std/crypto/Certificate/Bundle.zig +15 -1
  90. package/std/crypto/codecs/asn1.zig +33 -18
  91. package/std/crypto/codecs/base64_hex_ct.zig +14 -4
  92. package/std/debug/Dwarf.zig +29 -9
  93. package/std/debug/Info.zig +4 -0
  94. package/std/debug/MachOFile.zig +46 -8
  95. package/std/debug/Pdb.zig +539 -36
  96. package/std/debug/SelfInfo/Elf.zig +19 -18
  97. package/std/debug/SelfInfo/MachO.zig +18 -7
  98. package/std/debug/SelfInfo/Windows.zig +138 -36
  99. package/std/debug.zig +179 -65
  100. package/std/enums.zig +25 -19
  101. package/std/heap/ArenaAllocator.zig +145 -154
  102. package/std/heap/debug_allocator.zig +7 -7
  103. package/std/http/Client.zig +10 -6
  104. package/std/http.zig +11 -9
  105. package/std/json/Stringify.zig +3 -3
  106. package/std/json/dynamic.zig +4 -4
  107. package/std/math/big/int.zig +16 -17
  108. package/std/mem/Allocator.zig +4 -5
  109. package/std/mem.zig +48 -0
  110. package/std/os/emscripten.zig +1 -17
  111. package/std/os/linux.zig +7 -2
  112. package/std/os/windows.zig +2 -2
  113. package/std/pdb.zig +143 -4
  114. package/std/posix.zig +6 -12
  115. package/std/priority_dequeue.zig +13 -12
  116. package/std/priority_queue.zig +5 -4
  117. package/std/process/Child.zig +1 -1
  118. package/std/process/Environ.zig +1 -1
  119. package/std/start.zig +17 -4
  120. package/std/std.zig +19 -6
  121. package/std/testing/FailingAllocator.zig +4 -4
  122. package/std/testing/Smith.zig +37 -2
  123. package/std/zig/Ast/Render.zig +186 -458
  124. package/std/zig/Ast.zig +0 -4
  125. package/std/zig/AstGen.zig +44 -7
  126. package/std/zig/AstSmith.zig +2602 -0
  127. package/std/zig/Client.zig +8 -3
  128. package/std/zig/Parse.zig +83 -74
  129. package/std/zig/Server.zig +26 -0
  130. package/std/zig/Zir.zig +17 -0
  131. package/std/zig/c_translation/helpers.zig +14 -9
  132. package/std/zig/llvm/Builder.zig +107 -48
  133. package/std/zig/system.zig +20 -4
  134. package/std/zig/tokenizer.zig +2 -1
  135. package/std/zig.zig +6 -0
  136. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  137. package/libc/mingw/complex/cabs.c +0 -48
  138. package/libc/mingw/complex/cabsf.c +0 -48
  139. package/libc/mingw/complex/cacos.c +0 -50
  140. package/libc/mingw/complex/cacosf.c +0 -50
  141. package/libc/mingw/complex/carg.c +0 -48
  142. package/libc/mingw/complex/cargf.c +0 -48
  143. package/libc/mingw/complex/casin.c +0 -50
  144. package/libc/mingw/complex/casinf.c +0 -50
  145. package/libc/mingw/complex/catan.c +0 -50
  146. package/libc/mingw/complex/catanf.c +0 -50
  147. package/libc/mingw/complex/ccos.c +0 -50
  148. package/libc/mingw/complex/ccosf.c +0 -50
  149. package/libc/mingw/complex/cexp.c +0 -48
  150. package/libc/mingw/complex/cexpf.c +0 -48
  151. package/libc/mingw/complex/cimag.c +0 -48
  152. package/libc/mingw/complex/cimagf.c +0 -48
  153. package/libc/mingw/complex/clog.c +0 -48
  154. package/libc/mingw/complex/clog10.c +0 -49
  155. package/libc/mingw/complex/clog10f.c +0 -49
  156. package/libc/mingw/complex/clogf.c +0 -48
  157. package/libc/mingw/complex/conj.c +0 -48
  158. package/libc/mingw/complex/conjf.c +0 -48
  159. package/libc/mingw/complex/cpow.c +0 -48
  160. package/libc/mingw/complex/cpowf.c +0 -48
  161. package/libc/mingw/complex/cproj.c +0 -48
  162. package/libc/mingw/complex/cprojf.c +0 -48
  163. package/libc/mingw/complex/creal.c +0 -48
  164. package/libc/mingw/complex/crealf.c +0 -48
  165. package/libc/mingw/complex/csin.c +0 -50
  166. package/libc/mingw/complex/csinf.c +0 -50
  167. package/libc/mingw/complex/csqrt.c +0 -48
  168. package/libc/mingw/complex/csqrtf.c +0 -48
  169. package/libc/mingw/complex/ctan.c +0 -50
  170. package/libc/mingw/complex/ctanf.c +0 -50
  171. package/libc/mingw/math/arm/s_rint.c +0 -86
  172. package/libc/mingw/math/arm/s_rintf.c +0 -51
  173. package/libc/mingw/math/arm/sincos.S +0 -30
  174. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  175. package/libc/mingw/math/arm64/rint.c +0 -12
  176. package/libc/mingw/math/arm64/rintf.c +0 -12
  177. package/libc/mingw/math/arm64/sincos.S +0 -32
  178. package/libc/mingw/math/bsd_private_base.h +0 -148
  179. package/libc/mingw/math/frexpf.c +0 -13
  180. package/libc/mingw/math/frexpl.c +0 -71
  181. package/libc/mingw/math/x86/acosf.c +0 -29
  182. package/libc/mingw/math/x86/atanf.c +0 -23
  183. package/libc/mingw/math/x86/atanl.c +0 -18
  184. package/libc/mingw/math/x86/cos.def.h +0 -65
  185. package/libc/mingw/math/x86/cosl.c +0 -46
  186. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  187. package/libc/mingw/math/x86/ldexp.c +0 -23
  188. package/libc/mingw/math/x86/scalbn.S +0 -41
  189. package/libc/mingw/math/x86/scalbnf.S +0 -40
  190. package/libc/mingw/math/x86/sin.def.h +0 -65
  191. package/libc/mingw/math/x86/sinl.c +0 -46
  192. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  193. package/libc/mingw/math/x86/tanl.S +0 -62
  194. package/libc/mingw/misc/btowc.c +0 -28
  195. package/libc/mingw/misc/wcstof.c +0 -66
  196. package/libc/mingw/misc/wcstoimax.c +0 -132
  197. package/libc/mingw/misc/wcstoumax.c +0 -126
  198. package/libc/mingw/misc/wctob.c +0 -29
  199. package/libc/mingw/misc/winbs_uint64.c +0 -6
  200. package/libc/mingw/misc/winbs_ulong.c +0 -6
  201. package/libc/mingw/misc/winbs_ushort.c +0 -6
  202. package/libc/mingw/stdio/_Exit.c +0 -10
  203. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  204. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  205. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  206. package/libc/mingw/stdio/_stat64i32.c +0 -37
  207. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  208. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  209. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  210. package/libc/musl/src/legacy/isastream.c +0 -7
  211. package/libc/musl/src/legacy/valloc.c +0 -8
  212. package/libc/musl/src/math/__cosl.c +0 -96
  213. package/libc/musl/src/math/__sinl.c +0 -78
  214. package/libc/musl/src/math/__tanl.c +0 -143
  215. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  216. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  217. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  218. package/libc/musl/src/math/cosl.c +0 -39
  219. package/libc/musl/src/math/fdim.c +0 -10
  220. package/libc/musl/src/math/finite.c +0 -7
  221. package/libc/musl/src/math/finitef.c +0 -7
  222. package/libc/musl/src/math/frexp.c +0 -23
  223. package/libc/musl/src/math/frexpf.c +0 -23
  224. package/libc/musl/src/math/frexpl.c +0 -29
  225. package/libc/musl/src/math/i386/lrint.c +0 -8
  226. package/libc/musl/src/math/i386/lrintf.c +0 -8
  227. package/libc/musl/src/math/i386/rintf.c +0 -7
  228. package/libc/musl/src/math/lrint.c +0 -72
  229. package/libc/musl/src/math/lrintf.c +0 -8
  230. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  231. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  232. package/libc/musl/src/math/rintf.c +0 -30
  233. package/libc/musl/src/math/s390x/rintf.c +0 -15
  234. package/libc/musl/src/math/sincosl.c +0 -60
  235. package/libc/musl/src/math/sinl.c +0 -41
  236. package/libc/musl/src/math/tanl.c +0 -29
  237. package/libc/musl/src/math/x32/lrint.s +0 -5
  238. package/libc/musl/src/math/x32/lrintf.s +0 -5
  239. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  240. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  241. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
@@ -857,16 +857,8 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
857
857
  len: usize,
858
858
  new_items: []const T,
859
859
  ) Allocator.Error!void {
860
- const after_range = start + len;
861
- const range = self.items[start..after_range];
862
- if (range.len < new_items.len) {
863
- const first = new_items[0..range.len];
864
- const rest = new_items[range.len..];
865
- @memcpy(range[0..first.len], first);
866
- try self.insertSlice(gpa, after_range, rest);
867
- } else {
868
- self.replaceRangeAssumeCapacity(start, len, new_items);
869
- }
860
+ try self.ensureTotalCapacity(gpa, try addOrOom(self.items.len - len, new_items.len));
861
+ self.replaceRangeAssumeCapacity(start, len, new_items);
870
862
  }
871
863
 
872
864
  /// Grows or shrinks the list as necessary.
@@ -874,26 +866,20 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
874
866
  /// Never invalidates element pointers.
875
867
  ///
876
868
  /// Asserts the capacity is enough for additional items.
877
- pub fn replaceRangeAssumeCapacity(self: *Self, start: usize, len: usize, new_items: []const T) void {
878
- const after_range = start + len;
879
- const range = self.items[start..after_range];
880
-
881
- if (range.len == new_items.len)
882
- @memcpy(range[0..new_items.len], new_items)
883
- else if (range.len < new_items.len) {
884
- const first = new_items[0..range.len];
885
- const rest = new_items[range.len..];
886
- @memcpy(range[0..first.len], first);
887
- const dst = self.addManyAtAssumeCapacity(after_range, rest.len);
888
- @memcpy(dst, rest);
889
- } else {
890
- const extra = range.len - new_items.len;
891
- @memcpy(range[0..new_items.len], new_items);
892
- const src = self.items[after_range..];
893
- @memmove(self.items[after_range - extra ..][0..src.len], src);
894
- @memset(self.items[self.items.len - extra ..], undefined);
895
- self.items.len -= extra;
896
- }
869
+ pub fn replaceRangeAssumeCapacity(
870
+ self: *Self,
871
+ start: usize,
872
+ len: usize,
873
+ new_items: []const T,
874
+ ) void {
875
+ std.debug.assert(self.capacity - self.items.len >= new_items.len -| len);
876
+
877
+ const tail = self.items[start + len ..];
878
+ const vacated = self.items[self.items.len - (len -| new_items.len) ..];
879
+ self.items.len = self.items.len - len + new_items.len;
880
+ @memmove(self.items[start + new_items.len ..], tail);
881
+ @memcpy(self.items[start..][0..new_items.len], new_items);
882
+ @memset(vacated, undefined);
897
883
  }
898
884
 
899
885
  /// Grows or shrinks the list as necessary.
@@ -902,7 +888,12 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
902
888
  ///
903
889
  /// If the unused capacity is insufficient for additional items,
904
890
  /// returns `error.OutOfMemory`.
905
- pub fn replaceRangeBounded(self: *Self, start: usize, len: usize, new_items: []const T) error{OutOfMemory}!void {
891
+ pub fn replaceRangeBounded(
892
+ self: *Self,
893
+ start: usize,
894
+ len: usize,
895
+ new_items: []const T,
896
+ ) error{OutOfMemory}!void {
906
897
  if (self.capacity - self.items.len < new_items.len -| len) return error.OutOfMemory;
907
898
  return replaceRangeAssumeCapacity(self, start, len, new_items);
908
899
  }
package/std/bit_set.zig CHANGED
@@ -68,16 +68,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
68
68
  /// The bit mask, as a single integer
69
69
  mask: MaskInt,
70
70
 
71
+ /// Deprecated: use `.empty`.
71
72
  /// Creates a bit set with no elements present.
72
73
  pub fn initEmpty() Self {
73
74
  return .{ .mask = 0 };
74
75
  }
75
76
 
77
+ /// Deprecated: use `.full`.
76
78
  /// Creates a bit set with all elements present.
77
79
  pub fn initFull() Self {
78
80
  return .{ .mask = ~@as(MaskInt, 0) };
79
81
  }
80
82
 
83
+ /// A bit set with no elements present.
84
+ pub const empty: Self = .{ .mask = 0 };
85
+
86
+ /// A bit set with all elements present.
87
+ pub const full: Self = .{ .mask = ~@as(MaskInt, 0) };
88
+
81
89
  /// Returns the number of bits in this bit set
82
90
  pub inline fn capacity(self: Self) usize {
83
91
  _ = self;
@@ -387,11 +395,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
387
395
  /// Padding bits at the end are undefined.
388
396
  masks: [num_masks]MaskInt,
389
397
 
398
+ /// Deprecated: use `.empty`.
390
399
  /// Creates a bit set with no elements present.
391
400
  pub fn initEmpty() Self {
392
401
  return .{ .masks = [_]MaskInt{0} ** num_masks };
393
402
  }
394
403
 
404
+ /// Deprecated: use `.full`.
395
405
  /// Creates a bit set with all elements present.
396
406
  pub fn initFull() Self {
397
407
  if (num_masks == 0) {
@@ -401,6 +411,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
401
411
  }
402
412
  }
403
413
 
414
+ /// A bit set with no elements present.
415
+ pub const empty: Self = .{ .masks = @splat(0) };
416
+
417
+ /// A bit set with all elements present.
418
+ pub const full: Self = .{ .masks = if (num_masks == 0) .{} else ([_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask}) };
419
+
404
420
  /// Returns the number of bits in this bit set
405
421
  pub inline fn capacity(self: Self) usize {
406
422
  _ = self;
@@ -1633,17 +1649,17 @@ fn fillOdd(set: anytype, len: usize) void {
1633
1649
  }
1634
1650
 
1635
1651
  fn testPureBitSet(comptime Set: type) !void {
1636
- const empty = Set.initEmpty();
1637
- const full = Set.initFull();
1652
+ const empty = Set.empty;
1653
+ const full = Set.full;
1638
1654
 
1639
1655
  const even = even: {
1640
- var bit_set = Set.initEmpty();
1656
+ var bit_set = Set.empty;
1641
1657
  fillEven(&bit_set, Set.bit_length);
1642
1658
  break :even bit_set;
1643
1659
  };
1644
1660
 
1645
1661
  const odd = odd: {
1646
- var bit_set = Set.initEmpty();
1662
+ var bit_set = Set.empty;
1647
1663
  fillOdd(&bit_set, Set.bit_length);
1648
1664
  break :odd bit_set;
1649
1665
  };
@@ -1686,8 +1702,8 @@ fn testPureBitSet(comptime Set: type) !void {
1686
1702
  }
1687
1703
 
1688
1704
  fn testStaticBitSet(comptime Set: type) !void {
1689
- var a = Set.initEmpty();
1690
- var b = Set.initFull();
1705
+ var a = Set.empty;
1706
+ var b = Set.full;
1691
1707
  try testing.expectEqual(@as(usize, 0), a.count());
1692
1708
  try testing.expectEqual(@as(usize, Set.bit_length), b.count());
1693
1709
 
@@ -682,6 +682,40 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
682
682
  x30: bool = false,
683
683
  x31: bool = false,
684
684
 
685
+ // ABI aliases for integer registers
686
+ ra: bool = false,
687
+ sp: bool = false,
688
+ gp: bool = false,
689
+ tp: bool = false,
690
+ t0: bool = false,
691
+ t1: bool = false,
692
+ t2: bool = false,
693
+ s0: bool = false,
694
+ fp: bool = false,
695
+ s1: bool = false,
696
+ a0: bool = false,
697
+ a1: bool = false,
698
+ a2: bool = false,
699
+ a3: bool = false,
700
+ a4: bool = false,
701
+ a5: bool = false,
702
+ a6: bool = false,
703
+ a7: bool = false,
704
+ s2: bool = false,
705
+ s3: bool = false,
706
+ s4: bool = false,
707
+ s5: bool = false,
708
+ s6: bool = false,
709
+ s7: bool = false,
710
+ s8: bool = false,
711
+ s9: bool = false,
712
+ s10: bool = false,
713
+ s11: bool = false,
714
+ t3: bool = false,
715
+ t4: bool = false,
716
+ t5: bool = false,
717
+ t6: bool = false,
718
+
685
719
  fflags: bool = false,
686
720
  frm: bool = false,
687
721
 
@@ -718,6 +752,40 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
718
752
  f30: bool = false,
719
753
  f31: bool = false,
720
754
 
755
+ // ABI aliases for float registers
756
+ ft0: bool = false,
757
+ ft1: bool = false,
758
+ ft2: bool = false,
759
+ ft3: bool = false,
760
+ ft4: bool = false,
761
+ ft5: bool = false,
762
+ ft6: bool = false,
763
+ ft7: bool = false,
764
+ fs0: bool = false,
765
+ fs1: bool = false,
766
+ fa0: bool = false,
767
+ fa1: bool = false,
768
+ fa2: bool = false,
769
+ fa3: bool = false,
770
+ fa4: bool = false,
771
+ fa5: bool = false,
772
+ fa6: bool = false,
773
+ fa7: bool = false,
774
+ fs2: bool = false,
775
+ fs3: bool = false,
776
+ fs4: bool = false,
777
+ fs5: bool = false,
778
+ fs6: bool = false,
779
+ fs7: bool = false,
780
+ fs8: bool = false,
781
+ fs9: bool = false,
782
+ fs10: bool = false,
783
+ fs11: bool = false,
784
+ ft8: bool = false,
785
+ ft9: bool = false,
786
+ ft10: bool = false,
787
+ ft11: bool = false,
788
+
721
789
  vtype: bool = false,
722
790
  vl: bool = false,
723
791
  vxsat: bool = false,
package/std/c.zig CHANGED
@@ -3721,14 +3721,14 @@ pub const W = switch (native_os) {
3721
3721
  pub fn TERMSIG(x: u32) SIG {
3722
3722
  return @enumFromInt(status(x));
3723
3723
  }
3724
- pub fn STOPSIG(x: u32) u32 {
3725
- return x >> 8;
3724
+ pub fn STOPSIG(x: u32) SIG {
3725
+ return @enumFromInt(x >> 8);
3726
3726
  }
3727
3727
  pub fn IFEXITED(x: u32) bool {
3728
3728
  return status(x) == 0;
3729
3729
  }
3730
3730
  pub fn IFSTOPPED(x: u32) bool {
3731
- return status(x) == stopped and STOPSIG(x) != 0x13;
3731
+ return status(x) == stopped and @as(u32, @intFromEnum(STOPSIG(x))) != 0x13;
3732
3732
  }
3733
3733
  pub fn IFSIGNALED(x: u32) bool {
3734
3734
  return status(x) != stopped and status(x) != 0;
@@ -3754,8 +3754,8 @@ pub const W = switch (native_os) {
3754
3754
  pub fn TERMSIG(s: u32) SIG {
3755
3755
  return @enumFromInt(s & 0x7f);
3756
3756
  }
3757
- pub fn STOPSIG(s: u32) u32 {
3758
- return EXITSTATUS(s);
3757
+ pub fn STOPSIG(s: u32) SIG {
3758
+ return @enumFromInt(EXITSTATUS(s));
3759
3759
  }
3760
3760
  pub fn IFEXITED(s: u32) bool {
3761
3761
  return (s & 0x7f) == 0;
@@ -3782,8 +3782,8 @@ pub const W = switch (native_os) {
3782
3782
  pub fn TERMSIG(s: u32) SIG {
3783
3783
  return @enumFromInt(s & 0x7f);
3784
3784
  }
3785
- pub fn STOPSIG(s: u32) u32 {
3786
- return EXITSTATUS(s);
3785
+ pub fn STOPSIG(s: u32) SIG {
3786
+ return @enumFromInt(EXITSTATUS(s));
3787
3787
  }
3788
3788
  pub fn IFEXITED(s: u32) bool {
3789
3789
  return (s & 0x7f) == 0;
@@ -3816,8 +3816,8 @@ pub const W = switch (native_os) {
3816
3816
  pub fn TERMSIG(s: u32) SIG {
3817
3817
  return @enumFromInt(s & 0x7f);
3818
3818
  }
3819
- pub fn STOPSIG(s: u32) u32 {
3820
- return EXITSTATUS(s);
3819
+ pub fn STOPSIG(s: u32) SIG {
3820
+ return @enumFromInt(EXITSTATUS(s));
3821
3821
  }
3822
3822
  pub fn IFEXITED(s: u32) bool {
3823
3823
  return (s & 0x7f) == 0;
@@ -3850,8 +3850,8 @@ pub const W = switch (native_os) {
3850
3850
  pub fn TERMSIG(s: u32) SIG {
3851
3851
  return @enumFromInt(s & 0x7f);
3852
3852
  }
3853
- pub fn STOPSIG(s: u32) u32 {
3854
- return EXITSTATUS(s);
3853
+ pub fn STOPSIG(s: u32) SIG {
3854
+ return @enumFromInt(EXITSTATUS(s));
3855
3855
  }
3856
3856
  pub fn IFEXITED(s: u32) bool {
3857
3857
  return (s & 0x7f) == 0;
@@ -3879,8 +3879,8 @@ pub const W = switch (native_os) {
3879
3879
  return @enumFromInt((s >> 8) & 0xff);
3880
3880
  }
3881
3881
 
3882
- pub fn STOPSIG(s: u32) u32 {
3883
- return (s >> 16) & 0xff;
3882
+ pub fn STOPSIG(s: u32) SIG {
3883
+ return @enumFromInt((s >> 16) & 0xff);
3884
3884
  }
3885
3885
 
3886
3886
  pub fn IFEXITED(s: u32) bool {
@@ -3906,8 +3906,8 @@ pub const W = switch (native_os) {
3906
3906
  pub fn TERMSIG(s: u32) SIG {
3907
3907
  return @enumFromInt(s & 0x7f);
3908
3908
  }
3909
- pub fn STOPSIG(s: u32) u32 {
3910
- return EXITSTATUS(s);
3909
+ pub fn STOPSIG(s: u32) SIG {
3910
+ return @enumFromInt(EXITSTATUS(s));
3911
3911
  }
3912
3912
  pub fn IFEXITED(s: u32) bool {
3913
3913
  return (s & 0x7f) == 0;
@@ -3938,8 +3938,8 @@ pub const W = switch (native_os) {
3938
3938
  return @intCast((s & 0xff00) >> 8);
3939
3939
  }
3940
3940
 
3941
- pub fn STOPSIG(s: u32) u32 {
3942
- return EXITSTATUS(s);
3941
+ pub fn STOPSIG(s: u32) SIG {
3942
+ return @enumFromInt(EXITSTATUS(s));
3943
3943
  }
3944
3944
 
3945
3945
  pub fn TERMSIG(s: u32) SIG {
@@ -1488,7 +1488,7 @@ const PackedContainer = packed struct(u2) {
1488
1488
 
1489
1489
  test Compress {
1490
1490
  const fbufs = try testingFreqBufs();
1491
- defer if (!builtin.fuzz) std.testing.allocator.destroy(fbufs);
1491
+ defer std.testing.allocator.destroy(fbufs);
1492
1492
  try std.testing.fuzz(fbufs, testFuzzedCompressInput, .{});
1493
1493
  }
1494
1494
 
@@ -1818,7 +1818,7 @@ pub const Raw = struct {
1818
1818
 
1819
1819
  test Raw {
1820
1820
  const data_buf = try std.testing.allocator.create([4 * 65536]u8);
1821
- defer if (!builtin.fuzz) std.testing.allocator.destroy(data_buf);
1821
+ defer std.testing.allocator.destroy(data_buf);
1822
1822
  var prng: std.Random.DefaultPrng = .init(std.testing.random_seed);
1823
1823
  prng.random().bytes(data_buf);
1824
1824
  try std.testing.fuzz(data_buf, testFuzzedRawInput, .{});
@@ -2491,7 +2491,7 @@ pub const Huffman = struct {
2491
2491
 
2492
2492
  test Huffman {
2493
2493
  const fbufs = try testingFreqBufs();
2494
- defer if (!builtin.fuzz) std.testing.allocator.destroy(fbufs);
2494
+ defer std.testing.allocator.destroy(fbufs);
2495
2495
  try std.testing.fuzz(fbufs, testFuzzedHuffmanInput, .{});
2496
2496
  }
2497
2497
 
@@ -184,7 +184,8 @@ pub fn addCertsFromDirPath(
184
184
  ) AddCertsFromDirPathError!void {
185
185
  var iterable_dir = try dir.openDir(io, sub_dir_path, .{ .iterate = true });
186
186
  defer iterable_dir.close(io);
187
- return addCertsFromDir(cb, gpa, io, iterable_dir);
187
+ const now = Io.Clock.real.now(io);
188
+ return addCertsFromDir(cb, gpa, io, now, iterable_dir);
188
189
  }
189
190
 
190
191
  pub fn addCertsFromDirPathAbsolute(
@@ -331,6 +332,19 @@ const MapContext = struct {
331
332
  }
332
333
  };
333
334
 
335
+ test "addCertsFromDirPath compiles and accepts an empty directory" {
336
+ const io = std.testing.io;
337
+ const gpa = std.testing.allocator;
338
+
339
+ var tmp = std.testing.tmpDir(.{ .iterate = true });
340
+ defer tmp.cleanup();
341
+
342
+ var bundle: Bundle = .empty;
343
+ defer bundle.deinit(gpa);
344
+
345
+ try bundle.addCertsFromDirPath(gpa, io, tmp.dir, ".");
346
+ }
347
+
334
348
  test "scan for OS-provided certificates" {
335
349
  if (builtin.os.tag == .wasi) return error.SkipZigTest;
336
350
 
@@ -73,13 +73,13 @@ pub const Tag = struct {
73
73
  const tag1: FirstTag = @bitCast(try reader.takeByte());
74
74
  var number: u14 = tag1.number;
75
75
 
76
- if (tag1.number == 15) {
76
+ if (tag1.number == 31) {
77
77
  const tag2: NextTag = @bitCast(try reader.takeByte());
78
78
  number = tag2.number;
79
79
  if (tag2.continues) {
80
80
  const tag3: NextTag = @bitCast(try reader.takeByte());
81
81
  number = (number << 7) + tag3.number;
82
- if (tag3.continues) return error.InvalidLength;
82
+ if (tag3.continues) return error.EndOfStream;
83
83
  }
84
84
  }
85
85
 
@@ -183,7 +183,7 @@ pub const Element = struct {
183
183
  }
184
184
  };
185
185
 
186
- pub const DecodeError = error{ InvalidLength, EndOfStream };
186
+ pub const DecodeError = error{EndOfStream};
187
187
 
188
188
  /// Safely decode a DER/BER/CER element at `index`:
189
189
  /// - Ensures length uses shortest form
@@ -192,26 +192,35 @@ pub const Element = struct {
192
192
  pub fn decode(bytes: []const u8, index: Index) DecodeError!Element {
193
193
  var reader: std.Io.Reader = .fixed(bytes[index..]);
194
194
 
195
- const tag = try Tag.decode(&reader);
196
- const size_or_len_size = try reader.takeByte();
195
+ const tag = Tag.decode(&reader) catch |err| switch (err) {
196
+ error.ReadFailed => unreachable, // it's all fixed buffers
197
+ else => |e| return e,
198
+ };
199
+ const size_or_len_size = reader.takeByte() catch |err| switch (err) {
200
+ error.ReadFailed => unreachable, // it's all fixed buffers
201
+ else => |e| return e,
202
+ };
197
203
 
198
- var start = index + 2;
199
- var end = start + size_or_len_size;
200
- // short form between 0-127
201
- if (size_or_len_size < 128) {
202
- if (end > bytes.len) return error.InvalidLength;
203
- } else {
204
+ const len = if (size_or_len_size < 128)
205
+ // short form between 0-127
206
+ size_or_len_size
207
+ else blk: {
204
208
  // long form between 0 and std.math.maxInt(u1024)
205
209
  const len_size: u7 = @truncate(size_or_len_size);
206
- start += len_size;
207
- if (len_size > @sizeOf(Index)) return error.InvalidLength;
210
+ if (len_size > @sizeOf(Index)) return error.EndOfStream;
208
211
 
209
- const len = try reader.takeVarInt(Index, .big, len_size);
210
- if (len < 128) return error.InvalidLength; // should have used short form
212
+ const len = reader.takeVarInt(Index, .big, len_size) catch |err| switch (err) {
213
+ error.ReadFailed => unreachable, // it's all fixed buffers
214
+ else => |e| return e,
215
+ };
216
+ if (len < 128) return error.EndOfStream; // should have used short form
211
217
 
212
- end = std.math.add(Index, start, len) catch return error.InvalidLength;
213
- if (end > bytes.len) return error.InvalidLength;
214
- }
218
+ break :blk len;
219
+ };
220
+
221
+ const start = index + @as(Index, @intCast(reader.seek));
222
+ const end = std.math.add(Index, start, len) catch return error.EndOfStream;
223
+ if (end > bytes.len) return error.EndOfStream;
215
224
 
216
225
  return Element{ .tag = tag, .slice = Slice{ .start = start, .end = end } };
217
226
  }
@@ -229,6 +238,12 @@ test Element {
229
238
  .tag = Tag.universal(.sequence, true),
230
239
  .slice = Element.Slice{ .start = 3, .end = long_form.len },
231
240
  }, Element.decode(&long_form, 0));
241
+
242
+ const multi_byte_tag = [_]u8{ 0x1F, 0x20, 0x08, 0x30, 0x36, 0x3A, 0x32, 0x37, 0x3A, 0x31, 0x35 };
243
+ try std.testing.expectEqual(Element{
244
+ .tag = Tag.universal(.time_of_day, false),
245
+ .slice = Element.Slice{ .start = 3, .end = multi_byte_tag.len },
246
+ }, Element.decode(&multi_byte_tag, 0));
232
247
  }
233
248
 
234
249
  /// For decoding.
@@ -93,7 +93,7 @@ pub const hex = struct {
93
93
  /// The decoder will skip any characters that are in the ignore list.
94
94
  /// The ignore list must not contain any valid hexadecimal characters.
95
95
  pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
96
- var ignored_chars = StaticBitSet(256).initEmpty();
96
+ var ignored_chars = StaticBitSet(256).empty;
97
97
  for (ignore_chars) |c| {
98
98
  switch (c) {
99
99
  '0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,
@@ -269,7 +269,7 @@ pub const base64 = struct {
269
269
 
270
270
  /// Creates a new decoder that ignores certain characters.
271
271
  pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
272
- var ignored_chars = StaticBitSet(256).initEmpty();
272
+ var ignored_chars = StaticBitSet(256).empty;
273
273
  for (ignore_chars) |c| {
274
274
  switch (c) {
275
275
  'A'...'Z', 'a'...'z', '0'...'9' => return error.InvalidCharacter,
@@ -304,7 +304,7 @@ pub const base64 = struct {
304
304
  return (lt(x, 26) & (x +% 'A')) |
305
305
  (ge(x, 26) & lt(x, 52) & (x +% 'a' -% 26)) |
306
306
  (ge(x, 52) & lt(x, 62) & (x +% '0' -% 52)) |
307
- (eq(x, 62) & '+') | (eq(x, 63) & if (urlsafe) '_' else '/');
307
+ (eq(x, 62) & if (urlsafe) '-' else '+') | (eq(x, 63) & if (urlsafe) '_' else '/');
308
308
  }
309
309
 
310
310
  fn byteFromChar(c: u8, comptime urlsafe: bool) u8 {
@@ -312,7 +312,7 @@ pub const base64 = struct {
312
312
  (ge(c, 'A') & le(c, 'Z') & (c -% 'A')) |
313
313
  (ge(c, 'a') & le(c, 'z') & (c -% 'a' +% 26)) |
314
314
  (ge(c, '0') & le(c, '9') & (c -% '0' +% 52)) |
315
- (eq(c, '+') & 62) | (eq(c, if (urlsafe) '_' else '/') & 63);
315
+ (eq(c, if (urlsafe) '-' else '+') & 62) | (eq(c, if (urlsafe) '_' else '/') & 63);
316
316
  return x | (eq(x, 0) & ~eq(c, 'A'));
317
317
  }
318
318
 
@@ -453,6 +453,16 @@ test "hex with ignored chars" {
453
453
  try testing.expectEqualSlices(u8, &expected, bin);
454
454
  }
455
455
 
456
+ test "base64 urlsafe" {
457
+ const input = [_]u8{ 0xfb, 0xff };
458
+ var enc_buf: [4]u8 = undefined;
459
+ var dec_buf: [2]u8 = undefined;
460
+ const encoded = try base64.encode(&enc_buf, &input, .urlsafe);
461
+ try testing.expectEqualSlices(u8, "-_8=", encoded);
462
+ const decoded = try base64.decode(&dec_buf, encoded, .urlsafe);
463
+ try testing.expectEqualSlices(u8, &input, decoded);
464
+ }
465
+
456
466
  test "base64 with ignored chars" {
457
467
  const encoded = "dGVzdCBi\r\nYXNlNjQ=\n";
458
468
  const expected = "test base64";
@@ -22,7 +22,9 @@ const cast = std.math.cast;
22
22
  const maxInt = std.math.maxInt;
23
23
  const ArrayList = std.ArrayList;
24
24
  const Endian = std.builtin.Endian;
25
- const Reader = std.Io.Reader;
25
+ const Io = std.Io;
26
+ const Reader = Io.Reader;
27
+ const Error = std.debug.SelfInfoError;
26
28
 
27
29
  const Dwarf = @This();
28
30
 
@@ -1218,6 +1220,7 @@ pub fn populateSrcLocCache(d: *Dwarf, gpa: Allocator, endian: Endian, cu: *Compi
1218
1220
  pub fn getLineNumberInfo(
1219
1221
  d: *Dwarf,
1220
1222
  gpa: Allocator,
1223
+ text_arena: Allocator,
1221
1224
  endian: Endian,
1222
1225
  compile_unit: *CompileUnit,
1223
1226
  target_address: u64,
@@ -1230,7 +1233,7 @@ pub fn getLineNumberInfo(
1230
1233
  const file_entry = &slc.files[file_index];
1231
1234
  if (file_entry.dir_index >= slc.directories.len) return bad();
1232
1235
  const dir_name = slc.directories[file_entry.dir_index].path;
1233
- const file_name = try std.fs.path.join(gpa, &.{ dir_name, file_entry.path });
1236
+ const file_name = try std.fs.path.join(text_arena, &.{ dir_name, file_entry.path });
1234
1237
  return .{
1235
1238
  .line = entry.line,
1236
1239
  .column = entry.column,
@@ -1543,21 +1546,38 @@ fn getStringGeneric(opt_str: ?[]const u8, offset: u64) ![:0]const u8 {
1543
1546
  return str[casted_offset..last :0];
1544
1547
  }
1545
1548
 
1546
- pub fn getSymbol(di: *Dwarf, gpa: Allocator, endian: Endian, address: u64) !std.debug.Symbol {
1549
+ pub fn getSymbols(
1550
+ di: *Dwarf,
1551
+ symbol_allocator: Allocator,
1552
+ text_arena: Allocator,
1553
+ endian: Endian,
1554
+ address: u64,
1555
+ resolve_inline_callers: bool,
1556
+ symbols: *std.ArrayList(std.debug.Symbol),
1557
+ ) std.debug.SelfInfoError!void {
1558
+ _ = resolve_inline_callers;
1559
+ const gpa = std.debug.getDebugInfoAllocator();
1560
+
1547
1561
  const compile_unit = di.findCompileUnit(endian, address) catch |err| switch (err) {
1548
- error.MissingDebugInfo, error.InvalidDebugInfo => return .unknown,
1549
- else => return err,
1562
+ error.EndOfStream => return error.MissingDebugInfo,
1563
+ error.Overflow => return error.InvalidDebugInfo,
1564
+ error.ReadFailed, error.InvalidDebugInfo, error.MissingDebugInfo => |e| return e,
1550
1565
  };
1551
- return .{
1566
+ try symbols.append(symbol_allocator, .{
1552
1567
  .name = di.getSymbolName(address),
1553
1568
  .compile_unit_name = compile_unit.die.getAttrString(di, endian, std.dwarf.AT.name, di.section(.debug_str), compile_unit) catch |err| switch (err) {
1554
1569
  error.MissingDebugInfo, error.InvalidDebugInfo => null,
1555
1570
  },
1556
- .source_location = di.getLineNumberInfo(gpa, endian, compile_unit, address) catch |err| switch (err) {
1571
+ .source_location = di.getLineNumberInfo(gpa, text_arena, endian, compile_unit, address) catch |err| switch (err) {
1557
1572
  error.MissingDebugInfo, error.InvalidDebugInfo => null,
1558
- else => return err,
1573
+ error.ReadFailed,
1574
+ error.EndOfStream,
1575
+ error.Overflow,
1576
+ error.StreamTooLong,
1577
+ => return error.InvalidDebugInfo,
1578
+ else => |e| return e,
1559
1579
  },
1560
- };
1580
+ });
1561
1581
  }
1562
1582
 
1563
1583
  /// DWARF5 7.4: "In the 32-bit DWARF format, all values that represent lengths of DWARF sections and
@@ -99,6 +99,10 @@ pub fn resolveAddresses(
99
99
  // due to split debug information. For now, we'll just resolve the addreses one by one.
100
100
  for (sorted_pc_addrs, output) |pc_addr, *src_loc| {
101
101
  const dwarf, const dwarf_pc_addr = mf.getDwarfForAddress(gpa, io, pc_addr) catch |err| switch (err) {
102
+ error.MissingDebugInfo => {
103
+ src_loc.* = .invalid;
104
+ continue;
105
+ },
102
106
  error.InvalidMachO, error.InvalidDwarf => return error.InvalidDebugInfo,
103
107
  else => |e| return e,
104
108
  };