@zigc/lib 0.16.0-test.1 → 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 (352) hide show
  1. package/LICENSE +19 -0
  2. package/c/fcntl.zig +6 -1
  3. package/c/inttypes.zig +0 -10
  4. package/c/math.zig +138 -114
  5. package/c/pthread.zig +57 -0
  6. package/c/search.zig +1 -27
  7. package/c/stdlib/drand48.zig +0 -57
  8. package/c/stdlib.zig +0 -100
  9. package/c/string.zig +20 -7
  10. package/c/strings.zig +0 -38
  11. package/c/stropts.zig +17 -0
  12. package/c/unistd.zig +27 -26
  13. package/c/wchar.zig +10 -0
  14. package/c.zig +3 -2
  15. package/compiler/aro/aro/Attribute/names.zig +604 -589
  16. package/compiler/aro/aro/Attribute.zig +202 -116
  17. package/compiler/aro/aro/Builtins/common.zig +874 -863
  18. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  19. package/compiler/aro/aro/Builtins.zig +0 -1
  20. package/compiler/aro/aro/CodeGen.zig +8 -7
  21. package/compiler/aro/aro/Compilation.zig +137 -111
  22. package/compiler/aro/aro/Diagnostics.zig +21 -17
  23. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  24. package/compiler/aro/aro/Driver.zig +138 -63
  25. package/compiler/aro/aro/LangOpts.zig +12 -2
  26. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  27. package/compiler/aro/aro/Parser.zig +352 -153
  28. package/compiler/aro/aro/Pragma.zig +3 -2
  29. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  30. package/compiler/aro/aro/Preprocessor.zig +136 -62
  31. package/compiler/aro/aro/Target.zig +17 -12
  32. package/compiler/aro/aro/Tokenizer.zig +31 -14
  33. package/compiler/aro/aro/Toolchain.zig +4 -7
  34. package/compiler/aro/aro/Tree.zig +178 -148
  35. package/compiler/aro/aro/TypeStore.zig +82 -24
  36. package/compiler/aro/aro/Value.zig +13 -17
  37. package/compiler/aro/aro/features.zig +1 -0
  38. package/compiler/aro/aro/pragmas/message.zig +3 -2
  39. package/compiler/aro/aro/pragmas/once.zig +0 -1
  40. package/compiler/aro/aro/record_layout.zig +3 -3
  41. package/compiler/aro/aro/text_literal.zig +3 -2
  42. package/compiler/aro/assembly_backend/x86_64.zig +7 -8
  43. package/compiler/aro/backend/Assembly.zig +1 -2
  44. package/compiler/aro/backend/Interner.zig +2 -2
  45. package/compiler/aro/backend/Ir.zig +100 -92
  46. package/compiler/aro/include/ptrcheck.h +49 -0
  47. package/compiler/aro/main.zig +26 -10
  48. package/compiler/build_runner.zig +1 -2
  49. package/compiler/objdump.zig +93 -0
  50. package/compiler/reduce/Walk.zig +7 -7
  51. package/compiler/reduce.zig +5 -1
  52. package/compiler/resinator/compile.zig +2 -2
  53. package/compiler/resinator/main.zig +7 -1
  54. package/compiler/resinator/preprocess.zig +1 -3
  55. package/compiler/std-docs.zig +8 -1
  56. package/compiler/test_runner.zig +194 -62
  57. package/compiler/translate-c/MacroTranslator.zig +80 -11
  58. package/compiler/translate-c/PatternList.zig +1 -9
  59. package/compiler/translate-c/Scope.zig +43 -6
  60. package/compiler/translate-c/Translator.zig +369 -127
  61. package/compiler/translate-c/ast.zig +19 -11
  62. package/compiler/translate-c/main.zig +76 -17
  63. package/compiler_rt/cos.zig +140 -53
  64. package/compiler_rt/divmodei4.zig +40 -17
  65. package/compiler_rt/exp.zig +1 -6
  66. package/compiler_rt/exp2.zig +1 -6
  67. package/compiler_rt/exp_f128.zig +377 -0
  68. package/compiler_rt/fabs.zig +0 -2
  69. package/compiler_rt/fma.zig +0 -2
  70. package/compiler_rt/fmax.zig +0 -2
  71. package/compiler_rt/fmin.zig +0 -2
  72. package/compiler_rt/fmod.zig +0 -2
  73. package/compiler_rt/limb64.zig +1127 -0
  74. package/compiler_rt/log.zig +0 -2
  75. package/compiler_rt/log10.zig +0 -2
  76. package/compiler_rt/log2.zig +0 -2
  77. package/compiler_rt/long_double.zig +37 -0
  78. package/compiler_rt/mulXi3.zig +1 -1
  79. package/compiler_rt/mulo.zig +6 -1
  80. package/compiler_rt/rem_pio2l.zig +173 -0
  81. package/compiler_rt/round.zig +0 -2
  82. package/compiler_rt/sin.zig +139 -56
  83. package/compiler_rt/sincos.zig +277 -72
  84. package/compiler_rt/sqrt.zig +0 -2
  85. package/compiler_rt/ssp.zig +1 -1
  86. package/compiler_rt/tan.zig +117 -48
  87. package/compiler_rt/trig.zig +256 -6
  88. package/compiler_rt/trunc.zig +0 -2
  89. package/compiler_rt/udivmodei4.zig +28 -0
  90. package/compiler_rt.zig +2 -0
  91. package/fuzzer.zig +857 -307
  92. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  93. package/libc/musl/src/math/pow.c +343 -0
  94. package/package.json +1 -1
  95. package/std/Build/Cache.zig +6 -6
  96. package/std/Build/Fuzz.zig +6 -19
  97. package/std/Build/Module.zig +1 -1
  98. package/std/Build/Step/CheckObject.zig +3 -3
  99. package/std/Build/Step/Compile.zig +18 -1
  100. package/std/Build/Step/ConfigHeader.zig +49 -33
  101. package/std/Build/Step/InstallArtifact.zig +18 -0
  102. package/std/Build/Step/Run.zig +538 -89
  103. package/std/Build/Step/TranslateC.zig +0 -6
  104. package/std/Build/Step.zig +10 -19
  105. package/std/Build/WebServer.zig +31 -19
  106. package/std/Build/abi.zig +47 -11
  107. package/std/Build.zig +17 -17
  108. package/std/Io/Dir.zig +7 -2
  109. package/std/Io/Dispatch.zig +5 -13
  110. package/std/Io/File/Reader.zig +3 -1
  111. package/std/Io/File/Writer.zig +8 -6
  112. package/std/Io/File.zig +1 -0
  113. package/std/Io/Kqueue.zig +2 -2
  114. package/std/Io/Reader.zig +8 -9
  115. package/std/Io/Semaphore.zig +112 -17
  116. package/std/Io/Terminal.zig +1 -1
  117. package/std/Io/Threaded.zig +352 -180
  118. package/std/Io/Uring.zig +15 -16
  119. package/std/Io/Writer.zig +46 -42
  120. package/std/Io/net.zig +11 -11
  121. package/std/Io.zig +1052 -20
  122. package/std/SemanticVersion.zig +1 -1
  123. package/std/Target/Query.zig +2 -2
  124. package/std/Target.zig +53 -7
  125. package/std/Thread.zig +8 -3
  126. package/std/array_hash_map.zig +105 -573
  127. package/std/array_list.zig +22 -31
  128. package/std/bit_set.zig +22 -6
  129. package/std/builtin/assembly.zig +68 -0
  130. package/std/builtin.zig +4 -0
  131. package/std/c/haiku.zig +3 -0
  132. package/std/c/serenity.zig +1 -6
  133. package/std/c.zig +106 -24
  134. package/std/compress/flate/Compress.zig +3 -3
  135. package/std/compress/flate/Decompress.zig +2 -3
  136. package/std/compress/zstd/Decompress.zig +2 -4
  137. package/std/crypto/Certificate/Bundle.zig +15 -1
  138. package/std/crypto/Certificate.zig +13 -1
  139. package/std/crypto/ascon.zig +75 -33
  140. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  141. package/std/crypto/codecs/asn1.zig +33 -18
  142. package/std/crypto/codecs/base64_hex_ct.zig +16 -8
  143. package/std/crypto/ml_kem.zig +2 -9
  144. package/std/crypto/tls/Client.zig +79 -4
  145. package/std/crypto/tls.zig +1 -1
  146. package/std/crypto.zig +1 -0
  147. package/std/debug/Dwarf.zig +29 -9
  148. package/std/debug/Info.zig +4 -0
  149. package/std/debug/MachOFile.zig +46 -8
  150. package/std/debug/Pdb.zig +540 -37
  151. package/std/debug/SelfInfo/Elf.zig +19 -18
  152. package/std/debug/SelfInfo/MachO.zig +18 -7
  153. package/std/debug/SelfInfo/Windows.zig +138 -36
  154. package/std/debug.zig +181 -66
  155. package/std/enums.zig +25 -19
  156. package/std/fmt.zig +8 -3
  157. package/std/fs/path.zig +6 -4
  158. package/std/heap/ArenaAllocator.zig +145 -154
  159. package/std/heap/BufferFirstAllocator.zig +165 -0
  160. package/std/heap/debug_allocator.zig +7 -7
  161. package/std/heap.zig +2 -126
  162. package/std/http/Client.zig +31 -30
  163. package/std/http.zig +14 -13
  164. package/std/json/Scanner.zig +2 -2
  165. package/std/json/Stringify.zig +3 -3
  166. package/std/json/dynamic.zig +4 -4
  167. package/std/math/big/int.zig +16 -17
  168. package/std/mem/Allocator.zig +4 -5
  169. package/std/mem.zig +48 -0
  170. package/std/os/emscripten.zig +2 -18
  171. package/std/os/linux/IoUring.zig +2 -0
  172. package/std/os/linux/aarch64.zig +41 -12
  173. package/std/os/linux/arc.zig +173 -0
  174. package/std/os/linux/arm.zig +41 -12
  175. package/std/os/linux/hexagon.zig +33 -11
  176. package/std/os/linux/loongarch32.zig +41 -13
  177. package/std/os/linux/loongarch64.zig +41 -12
  178. package/std/os/linux/m68k.zig +41 -13
  179. package/std/os/linux/mips.zig +67 -36
  180. package/std/os/linux/mips64.zig +60 -29
  181. package/std/os/linux/mipsn32.zig +60 -29
  182. package/std/os/linux/or1k.zig +41 -12
  183. package/std/os/linux/powerpc.zig +41 -12
  184. package/std/os/linux/powerpc64.zig +41 -12
  185. package/std/os/linux/riscv32.zig +41 -12
  186. package/std/os/linux/riscv64.zig +41 -12
  187. package/std/os/linux/s390x.zig +44 -7
  188. package/std/os/linux/sparc64.zig +83 -52
  189. package/std/os/linux/thumb.zig +52 -36
  190. package/std/os/linux/x32.zig +41 -12
  191. package/std/os/linux/x86.zig +42 -13
  192. package/std/os/linux/x86_64.zig +41 -12
  193. package/std/os/linux.zig +419 -438
  194. package/std/os/uefi/tables/boot_services.zig +9 -8
  195. package/std/os/windows.zig +2 -2
  196. package/std/os.zig +41 -0
  197. package/std/pdb.zig +143 -4
  198. package/std/posix.zig +6 -12
  199. package/std/priority_dequeue.zig +13 -12
  200. package/std/priority_queue.zig +5 -4
  201. package/std/process/Child.zig +1 -1
  202. package/std/process/Environ.zig +1 -1
  203. package/std/process.zig +1 -1
  204. package/std/sort.zig +3 -3
  205. package/std/start.zig +17 -4
  206. package/std/std.zig +19 -6
  207. package/std/testing/FailingAllocator.zig +4 -4
  208. package/std/testing/Smith.zig +37 -2
  209. package/std/zig/Ast/Render.zig +187 -459
  210. package/std/zig/Ast.zig +0 -4
  211. package/std/zig/AstGen.zig +86 -103
  212. package/std/zig/AstRlAnnotate.zig +0 -11
  213. package/std/zig/AstSmith.zig +2602 -0
  214. package/std/zig/BuiltinFn.zig +0 -32
  215. package/std/zig/Client.zig +8 -3
  216. package/std/zig/LibCInstallation.zig +4 -3
  217. package/std/zig/Parse.zig +90 -81
  218. package/std/zig/Server.zig +26 -0
  219. package/std/zig/WindowsSdk.zig +13 -13
  220. package/std/zig/Zir.zig +66 -62
  221. package/std/zig/ZonGen.zig +6 -5
  222. package/std/zig/c_translation/helpers.zig +14 -9
  223. package/std/zig/llvm/Builder.zig +119 -60
  224. package/std/zig/system.zig +20 -4
  225. package/std/zig/tokenizer.zig +2 -1
  226. package/std/zig.zig +7 -10
  227. package/std/zip.zig +5 -5
  228. package/zig.h +340 -1
  229. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  230. package/libc/mingw/complex/cabs.c +0 -48
  231. package/libc/mingw/complex/cabsf.c +0 -48
  232. package/libc/mingw/complex/cacos.c +0 -50
  233. package/libc/mingw/complex/cacosf.c +0 -50
  234. package/libc/mingw/complex/carg.c +0 -48
  235. package/libc/mingw/complex/cargf.c +0 -48
  236. package/libc/mingw/complex/casin.c +0 -50
  237. package/libc/mingw/complex/casinf.c +0 -50
  238. package/libc/mingw/complex/catan.c +0 -50
  239. package/libc/mingw/complex/catanf.c +0 -50
  240. package/libc/mingw/complex/ccos.c +0 -50
  241. package/libc/mingw/complex/ccosf.c +0 -50
  242. package/libc/mingw/complex/cexp.c +0 -48
  243. package/libc/mingw/complex/cexpf.c +0 -48
  244. package/libc/mingw/complex/cimag.c +0 -48
  245. package/libc/mingw/complex/cimagf.c +0 -48
  246. package/libc/mingw/complex/clog.c +0 -48
  247. package/libc/mingw/complex/clog10.c +0 -49
  248. package/libc/mingw/complex/clog10f.c +0 -49
  249. package/libc/mingw/complex/clogf.c +0 -48
  250. package/libc/mingw/complex/conj.c +0 -48
  251. package/libc/mingw/complex/conjf.c +0 -48
  252. package/libc/mingw/complex/cpow.c +0 -48
  253. package/libc/mingw/complex/cpowf.c +0 -48
  254. package/libc/mingw/complex/cproj.c +0 -48
  255. package/libc/mingw/complex/cprojf.c +0 -48
  256. package/libc/mingw/complex/creal.c +0 -48
  257. package/libc/mingw/complex/crealf.c +0 -48
  258. package/libc/mingw/complex/csin.c +0 -50
  259. package/libc/mingw/complex/csinf.c +0 -50
  260. package/libc/mingw/complex/csqrt.c +0 -48
  261. package/libc/mingw/complex/csqrtf.c +0 -48
  262. package/libc/mingw/complex/ctan.c +0 -50
  263. package/libc/mingw/complex/ctanf.c +0 -50
  264. package/libc/mingw/math/arm/s_rint.c +0 -86
  265. package/libc/mingw/math/arm/s_rintf.c +0 -51
  266. package/libc/mingw/math/arm/sincos.S +0 -30
  267. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  268. package/libc/mingw/math/arm64/rint.c +0 -12
  269. package/libc/mingw/math/arm64/rintf.c +0 -12
  270. package/libc/mingw/math/arm64/sincos.S +0 -32
  271. package/libc/mingw/math/bsd_private_base.h +0 -148
  272. package/libc/mingw/math/fdiml.c +0 -24
  273. package/libc/mingw/math/frexpf.c +0 -13
  274. package/libc/mingw/math/frexpl.c +0 -71
  275. package/libc/mingw/math/x86/acosf.c +0 -29
  276. package/libc/mingw/math/x86/atanf.c +0 -23
  277. package/libc/mingw/math/x86/atanl.c +0 -18
  278. package/libc/mingw/math/x86/cos.def.h +0 -65
  279. package/libc/mingw/math/x86/cosl.c +0 -46
  280. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  281. package/libc/mingw/math/x86/ldexp.c +0 -23
  282. package/libc/mingw/math/x86/scalbn.S +0 -41
  283. package/libc/mingw/math/x86/scalbnf.S +0 -40
  284. package/libc/mingw/math/x86/sin.def.h +0 -65
  285. package/libc/mingw/math/x86/sinl.c +0 -46
  286. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  287. package/libc/mingw/math/x86/tanl.S +0 -62
  288. package/libc/mingw/misc/btowc.c +0 -28
  289. package/libc/mingw/misc/wcstof.c +0 -66
  290. package/libc/mingw/misc/wcstoimax.c +0 -132
  291. package/libc/mingw/misc/wcstoumax.c +0 -126
  292. package/libc/mingw/misc/wctob.c +0 -29
  293. package/libc/mingw/misc/winbs_uint64.c +0 -6
  294. package/libc/mingw/misc/winbs_ulong.c +0 -6
  295. package/libc/mingw/misc/winbs_ushort.c +0 -6
  296. package/libc/mingw/stdio/_Exit.c +0 -10
  297. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  298. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  299. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  300. package/libc/mingw/stdio/_stat64i32.c +0 -37
  301. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  302. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  303. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  304. package/libc/mingw/winpthreads/spinlock.c +0 -82
  305. package/libc/musl/src/legacy/isastream.c +0 -7
  306. package/libc/musl/src/legacy/valloc.c +0 -8
  307. package/libc/musl/src/linux/tee.c +0 -8
  308. package/libc/musl/src/math/__cosl.c +0 -96
  309. package/libc/musl/src/math/__sinl.c +0 -78
  310. package/libc/musl/src/math/__tanl.c +0 -143
  311. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  312. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  313. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  314. package/libc/musl/src/math/cosl.c +0 -39
  315. package/libc/musl/src/math/fdim.c +0 -10
  316. package/libc/musl/src/math/fdimf.c +0 -10
  317. package/libc/musl/src/math/fdiml.c +0 -18
  318. package/libc/musl/src/math/finite.c +0 -7
  319. package/libc/musl/src/math/finitef.c +0 -7
  320. package/libc/musl/src/math/frexp.c +0 -23
  321. package/libc/musl/src/math/frexpf.c +0 -23
  322. package/libc/musl/src/math/frexpl.c +0 -29
  323. package/libc/musl/src/math/i386/lrint.c +0 -8
  324. package/libc/musl/src/math/i386/lrintf.c +0 -8
  325. package/libc/musl/src/math/i386/rintf.c +0 -7
  326. package/libc/musl/src/math/lrint.c +0 -72
  327. package/libc/musl/src/math/lrintf.c +0 -8
  328. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  329. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  330. package/libc/musl/src/math/rintf.c +0 -30
  331. package/libc/musl/src/math/s390x/rintf.c +0 -15
  332. package/libc/musl/src/math/sincosl.c +0 -60
  333. package/libc/musl/src/math/sinl.c +0 -41
  334. package/libc/musl/src/math/tanl.c +0 -29
  335. package/libc/musl/src/math/x32/lrint.s +0 -5
  336. package/libc/musl/src/math/x32/lrintf.s +0 -5
  337. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  338. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  339. package/libc/musl/src/string/strdup.c +0 -10
  340. package/libc/musl/src/string/strndup.c +0 -12
  341. package/libc/musl/src/string/wcsdup.c +0 -10
  342. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  343. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  344. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  345. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  346. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  347. package/libc/musl/src/unistd/dup2.c +0 -20
  348. package/libc/musl/src/unistd/dup3.c +0 -26
  349. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
  350. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  351. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  352. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
package/std/debug.zig CHANGED
@@ -13,7 +13,6 @@ const windows = std.os.windows;
13
13
  const builtin = @import("builtin");
14
14
  const native_arch = builtin.cpu.arch;
15
15
  const native_os = builtin.os.tag;
16
- const StackTrace = std.builtin.StackTrace;
17
16
 
18
17
  const root = @import("root");
19
18
 
@@ -39,8 +38,8 @@ pub const cpu_context = @import("debug/cpu_context.zig");
39
38
  /// pub const init: SelfInfo;
40
39
  /// pub fn deinit(si: *SelfInfo, io: Io) void;
41
40
  ///
42
- /// /// Returns the symbol and source location of the instruction at `address`.
43
- /// pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) SelfInfoError!Symbol;
41
+ /// /// Appends the symbols for the instruction at `address` to `symbols`.
42
+ /// pub fn getSymbols(si: *SelfInfo, io: Io, symbol_allocator: Allocator, text_arena: Allocator, address: usize, include_inline_callers: bool, symbols: *std.ArrayList(Symbol)) SelfInfoError!void;
44
43
  /// /// Returns a name for the "module" (e.g. shared library or executable image) containing `address`.
45
44
  /// pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) SelfInfoError![]const u8;
46
45
  /// pub fn getModuleSlide(si: *SelfInfo, io: Io, address: usize) SelfInfoError!usize;
@@ -563,7 +562,7 @@ pub fn defaultPanic(msg: []const u8, first_trace_addr: ?usize) noreturn {
563
562
 
564
563
  if (@errorReturnTrace()) |t| if (t.index > 0) {
565
564
  writer.writeAll("error return context:\n") catch break :trace;
566
- writeStackTrace(t, stderr) catch break :trace;
565
+ writeErrorReturnTrace(t, stderr) catch break :trace;
567
566
  writer.writeAll("\nstack trace:\n") catch break :trace;
568
567
  };
569
568
  writeCurrentStackTrace(.{
@@ -602,6 +601,35 @@ fn waitForOtherThreadToFinishPanicking() void {
602
601
  }
603
602
  }
604
603
 
604
+ pub const StackTrace = struct {
605
+ /// Each element is the "return address" of a function call, meaning the instruction address
606
+ /// which control flow will return to when the function returns.
607
+ ///
608
+ /// The first slice element corresponds to the innermost stack frame, and the last element to
609
+ /// the outermost.
610
+ ///
611
+ /// Inlined function calls do not have meaningful return addresses and are therefore not
612
+ /// included in this slice. Instead, when printing the stack trace, the source locations of
613
+ /// inline calls should be read from debug information and the corresponding "inline frames"
614
+ /// printed in the appropriate locations.
615
+ return_addresses: []usize,
616
+ /// Indicates whether any stack frames were omitted from `return_addresses`.
617
+ skipped: SkippedAddresses,
618
+ };
619
+
620
+ /// Indicates how many addresses were skipped in a trace.
621
+ pub const SkippedAddresses = enum(usize) {
622
+ /// No addresses were omitted: `return_addresses` contains all stack frames, including the
623
+ /// outermost.
624
+ none = 0,
625
+ /// It is not known whether any frames were omitted.
626
+ unknown = std.math.maxInt(usize),
627
+ /// The full stack trace was available, but some frames are not included in
628
+ /// `return_addresses` due to buffer size limitations. The enum value is the exact number of
629
+ /// addresses which were omitted.
630
+ _,
631
+ };
632
+
605
633
  pub const StackUnwindOptions = struct {
606
634
  /// If not `null`, we will ignore all frames up until this return address. This is typically
607
635
  /// used to omit intermediate handling code (for instance, a panic handler and its machinery)
@@ -621,7 +649,10 @@ pub const StackUnwindOptions = struct {
621
649
  ///
622
650
  /// See `writeCurrentStackTrace` to immediately print the trace instead of capturing it.
623
651
  pub noinline fn captureCurrentStackTrace(options: StackUnwindOptions, addr_buf: []usize) StackTrace {
624
- const empty_trace: StackTrace = .{ .index = 0, .instruction_addresses = &.{} };
652
+ const empty_trace: StackTrace = .{
653
+ .return_addresses = &.{},
654
+ .skipped = .none,
655
+ };
625
656
  if (!std.options.allow_stack_tracing) return empty_trace;
626
657
  var it: StackIterator = .init(options.context);
627
658
  defer it.deinit();
@@ -632,17 +663,17 @@ pub noinline fn captureCurrentStackTrace(options: StackUnwindOptions, addr_buf:
632
663
  var total_frames: usize = 0;
633
664
  var index: usize = 0;
634
665
  var wait_for = options.first_address;
635
- // Ideally, we would iterate the whole stack so that the `index` in the returned trace was
666
+ // Ideally, we would iterate the whole stack so that the `index - min(buf.len, index)` would be
636
667
  // indicative of how many frames were skipped. However, this has a significant runtime cost
637
668
  // in some cases, so at least for now, we don't do that.
638
- while (index < addr_buf.len) switch (it.next(io)) {
639
- .switch_to_fp => if (!it.stratOk(options.allow_unsafe_unwind)) break,
640
- .end => break,
669
+ const skipped: SkippedAddresses = while (index < addr_buf.len) switch (it.next(io)) {
670
+ .switch_to_fp => if (!it.stratOk(options.allow_unsafe_unwind)) break .unknown,
671
+ .end => break .none,
641
672
  .frame => |ret_addr| {
642
673
  if (total_frames > 10_000) {
643
674
  // Limit the number of frames in case of (e.g.) broken debug information which is
644
675
  // getting unwinding stuck in a loop.
645
- break;
676
+ break .unknown;
646
677
  }
647
678
  total_frames += 1;
648
679
  if (wait_for) |target| {
@@ -652,10 +683,10 @@ pub noinline fn captureCurrentStackTrace(options: StackUnwindOptions, addr_buf:
652
683
  addr_buf[index] = ret_addr;
653
684
  index += 1;
654
685
  },
655
- };
686
+ } else .unknown;
656
687
  return .{
657
- .index = index,
658
- .instruction_addresses = addr_buf[0..index],
688
+ .return_addresses = addr_buf[0..index],
689
+ .skipped = skipped,
659
690
  };
660
691
  }
661
692
  /// Write the current stack trace to `writer`, annotated with source locations.
@@ -663,6 +694,10 @@ pub noinline fn captureCurrentStackTrace(options: StackUnwindOptions, addr_buf:
663
694
  /// See `captureCurrentStackTrace` to capture the trace addresses into a buffer instead of printing.
664
695
  pub noinline fn writeCurrentStackTrace(options: StackUnwindOptions, t: Io.Terminal) Writer.Error!void {
665
696
  const writer = t.writer;
697
+
698
+ var text_arena: std.heap.ArenaAllocator = .init(getDebugInfoAllocator());
699
+ defer text_arena.deinit();
700
+
666
701
  if (!std.options.allow_stack_tracing) {
667
702
  t.setColor(.dim) catch {};
668
703
  try writer.print("Cannot print stack trace: stack tracing is disabled\n", .{});
@@ -740,7 +775,10 @@ pub noinline fn writeCurrentStackTrace(options: StackUnwindOptions, t: Io.Termin
740
775
  }
741
776
  // `ret_addr` is the return address, which is *after* the function call.
742
777
  // Subtract 1 to get an address *in* the function call for a better source location.
743
- try printSourceAtAddress(io, di, t, ret_addr -| StackIterator.ra_call_offset);
778
+ try printSourceAtAddress(io, &text_arena, di, t, .{
779
+ .address = ret_addr -| StackIterator.ra_call_offset,
780
+ .resolve_inline_callers = true,
781
+ });
744
782
  printed_any_frame = true;
745
783
  },
746
784
  };
@@ -773,8 +811,29 @@ pub const FormatStackTrace = struct {
773
811
  }
774
812
  };
775
813
 
814
+ /// Write a previously captured error return trace to `writer`, annotated with source locations.
815
+ pub fn writeErrorReturnTrace(et: *const std.builtin.StackTrace, t: Io.Terminal) Writer.Error!void {
816
+ // We take the slice by value, preventing the length from being mutated if an error occurs while
817
+ // writing the stack trace.
818
+ const len = @min(et.instruction_addresses.len, et.index);
819
+ const skipped = et.index - len;
820
+ try writeTrace(et.instruction_addresses[0..len], @enumFromInt(skipped), t, false);
821
+ }
822
+
776
823
  /// Write a previously captured stack trace to `writer`, annotated with source locations.
777
824
  pub fn writeStackTrace(st: *const StackTrace, t: Io.Terminal) Writer.Error!void {
825
+ try writeTrace(st.return_addresses, st.skipped, t, true);
826
+ }
827
+
828
+ fn writeTrace(
829
+ addresses: []const usize,
830
+ skipped: SkippedAddresses,
831
+ t: Io.Terminal,
832
+ resolve_inline_callers: bool,
833
+ ) Writer.Error!void {
834
+ var text_arena: std.heap.ArenaAllocator = .init(getDebugInfoAllocator());
835
+ defer text_arena.deinit();
836
+
778
837
  const writer = t.writer;
779
838
  if (!std.options.allow_stack_tracing) {
780
839
  t.setColor(.dim) catch {};
@@ -783,10 +842,7 @@ pub fn writeStackTrace(st: *const StackTrace, t: Io.Terminal) Writer.Error!void
783
842
  return;
784
843
  }
785
844
 
786
- // Fetch `st.index` straight away. Aside from avoiding redundant loads, this prevents issues if
787
- // `st` is `@errorReturnTrace()` and errors are encountered while writing the stack trace.
788
- const n_frames = st.index;
789
- if (n_frames == 0) return writer.writeAll("(empty stack trace)\n");
845
+ if (addresses.len == 0) return writer.writeAll("(empty stack trace)\n");
790
846
  const di = getSelfDebugInfo() catch |err| switch (err) {
791
847
  error.UnsupportedTarget => {
792
848
  t.setColor(.dim) catch {};
@@ -796,16 +852,26 @@ pub fn writeStackTrace(st: *const StackTrace, t: Io.Terminal) Writer.Error!void
796
852
  },
797
853
  };
798
854
  const io = std.Options.debug_io;
799
- const captured_frames = @min(n_frames, st.instruction_addresses.len);
800
- for (st.instruction_addresses[0..captured_frames]) |ret_addr| {
801
- // `ret_addr` is the return address, which is *after* the function call.
855
+ for (addresses) |addr| {
856
+ // `addr` is the return address, which is *after* the function call.
802
857
  // Subtract 1 to get an address *in* the function call for a better source location.
803
- try printSourceAtAddress(io, di, t, ret_addr -| StackIterator.ra_call_offset);
858
+ try printSourceAtAddress(io, &text_arena, di, t, .{
859
+ .address = addr -| StackIterator.ra_call_offset,
860
+ .resolve_inline_callers = resolve_inline_callers,
861
+ });
804
862
  }
805
- if (n_frames > captured_frames) {
806
- t.setColor(.bold) catch {};
807
- try writer.print("({d} additional stack frames skipped...)\n", .{n_frames - captured_frames});
808
- t.setColor(.reset) catch {};
863
+ switch (skipped) {
864
+ .none => {},
865
+ .unknown => {
866
+ t.setColor(.bold) catch {};
867
+ try writer.writeAll("(additional stack frames may have been skipped...)\n");
868
+ t.setColor(.reset) catch {};
869
+ },
870
+ else => |n| {
871
+ t.setColor(.bold) catch {};
872
+ try writer.print("({d} additional stack frames skipped due to buffer size limitations...)\n", .{n});
873
+ t.setColor(.reset) catch {};
874
+ },
809
875
  }
810
876
  }
811
877
  /// A thin wrapper around `writeStackTrace` which writes to stderr and ignores write errors.
@@ -817,6 +883,15 @@ pub fn dumpStackTrace(st: *const StackTrace) void {
817
883
  };
818
884
  }
819
885
 
886
+ /// A thin wrapper around `writeErrorReturnTrace` which writes to stderr and ignores write errors.
887
+ pub fn dumpErrorReturnTrace(et: *const std.builtin.StackTrace) void {
888
+ const stderr = lockStderr(&.{}).terminal();
889
+ defer unlockStderr();
890
+ writeErrorReturnTrace(et, stderr) catch |err| switch (err) {
891
+ error.WriteFailed => {},
892
+ };
893
+ }
894
+
820
895
  const StackIterator = union(enum) {
821
896
  /// We will first report the current PC of this `CpuContextPtr`, then we will switch to a
822
897
  /// different strategy to actually unwind.
@@ -1106,48 +1181,78 @@ pub inline fn stripInstructionPtrAuthCode(ptr: usize) usize {
1106
1181
  return ptr;
1107
1182
  }
1108
1183
 
1109
- fn printSourceAtAddress(io: Io, debug_info: *SelfInfo, t: Io.Terminal, address: usize) Writer.Error!void {
1110
- const symbol: Symbol = debug_info.getSymbol(io, address) catch |err| switch (err) {
1111
- error.MissingDebugInfo,
1112
- error.UnsupportedDebugInfo,
1113
- error.InvalidDebugInfo,
1114
- => .unknown,
1115
- error.ReadFailed, error.Unexpected, error.Canceled => s: {
1116
- t.setColor(.dim) catch {};
1117
- try t.writer.print("Failed to read debug info from filesystem, trace may be incomplete\n\n", .{});
1118
- t.setColor(.reset) catch {};
1119
- break :s .unknown;
1120
- },
1121
- error.OutOfMemory => s: {
1122
- t.setColor(.dim) catch {};
1123
- try t.writer.print("Ran out of memory loading debug info, trace may be incomplete\n\n", .{});
1124
- t.setColor(.reset) catch {};
1125
- break :s .unknown;
1126
- },
1127
- };
1128
- defer if (symbol.source_location) |sl| getDebugInfoAllocator().free(sl.file_name);
1129
- return printLineInfo(
1184
+ const PrintSourceAddressOptions = struct {
1185
+ address: usize,
1186
+ resolve_inline_callers: bool,
1187
+ };
1188
+
1189
+ fn printSourceAtAddress(
1190
+ io: Io,
1191
+ text_arena: *std.heap.ArenaAllocator,
1192
+ debug_info: *SelfInfo,
1193
+ t: Io.Terminal,
1194
+ options: PrintSourceAddressOptions,
1195
+ ) Writer.Error!void {
1196
+ defer _ = text_arena.reset(.retain_capacity);
1197
+
1198
+ // Initialize the symbol array with space for at least one element, allocating this on the stack
1199
+ // in the common case where only one element is needed
1200
+ var buf: [1]Symbol = undefined;
1201
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), getDebugInfoAllocator());
1202
+ const symbol_allocator = bfa.allocator();
1203
+ var symbols = std.ArrayList(Symbol).initCapacity(symbol_allocator, 1) catch unreachable;
1204
+ defer symbols.deinit(symbol_allocator);
1205
+
1206
+ debug_info.getSymbols(
1130
1207
  io,
1131
- t,
1132
- symbol.source_location,
1133
- address,
1134
- symbol.name orelse "???",
1135
- symbol.compile_unit_name orelse debug_info.getModuleName(io, address) catch "???",
1136
- );
1208
+ symbol_allocator,
1209
+ text_arena.allocator(),
1210
+ options.address,
1211
+ options.resolve_inline_callers,
1212
+ &symbols,
1213
+ ) catch |err| {
1214
+ t.setColor(.dim) catch {};
1215
+ defer t.setColor(.reset) catch {};
1216
+ switch (err) {
1217
+ error.MissingDebugInfo,
1218
+ error.UnsupportedDebugInfo,
1219
+ error.InvalidDebugInfo,
1220
+ => {},
1221
+ error.ReadFailed, error.Unexpected, error.Canceled => {
1222
+ try t.writer.print("Failed to read debug info from filesystem, trace may be incomplete\n\n", .{});
1223
+ },
1224
+ error.OutOfMemory => {
1225
+ t.setColor(.dim) catch {};
1226
+ try t.writer.print("Ran out of memory loading debug info, trace may be incomplete\n\n", .{});
1227
+ t.setColor(.reset) catch {};
1228
+ },
1229
+ }
1230
+ };
1231
+
1232
+ // If we failed to write any symbols, at least write the unknown symbol. Can't fail since we
1233
+ // initialized with a capacity of 1.
1234
+ if (symbols.items.len == 0) symbols.appendAssumeCapacity(.unknown);
1235
+
1236
+ for (symbols.items) |symbol| {
1237
+ try printLineInfo(io, t, debug_info, options.address, symbol);
1238
+ }
1137
1239
  }
1138
1240
  fn printLineInfo(
1139
1241
  io: Io,
1140
1242
  t: Io.Terminal,
1141
- source_location: ?SourceLocation,
1243
+ debug_info: *SelfInfo,
1142
1244
  address: usize,
1143
- symbol_name: []const u8,
1144
- compile_unit_name: []const u8,
1245
+ symbol: Symbol,
1145
1246
  ) Writer.Error!void {
1146
1247
  const writer = t.writer;
1147
1248
  t.setColor(.bold) catch {};
1148
1249
 
1149
- if (source_location) |*sl| {
1150
- try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });
1250
+ if (symbol.source_location) |*sl| {
1251
+ if (sl.column == 0) {
1252
+ try writer.print("{s}:{d}", .{ sl.file_name, sl.line });
1253
+ } else {
1254
+ try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });
1255
+ }
1151
1256
  } else {
1152
1257
  try writer.writeAll("???:?:?");
1153
1258
  }
@@ -1155,12 +1260,16 @@ fn printLineInfo(
1155
1260
  t.setColor(.reset) catch {};
1156
1261
  try writer.writeAll(": ");
1157
1262
  t.setColor(.dim) catch {};
1158
- try writer.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
1263
+ try writer.print("0x{x} in {s} ({s})", .{
1264
+ address,
1265
+ symbol.name orelse "???",
1266
+ symbol.compile_unit_name orelse debug_info.getModuleName(io, address) catch "???",
1267
+ });
1159
1268
  t.setColor(.reset) catch {};
1160
1269
  try writer.writeAll("\n");
1161
1270
 
1162
1271
  // Show the matching source code line if possible
1163
- if (source_location) |sl| {
1272
+ if (symbol.source_location) |sl| {
1164
1273
  if (printLineFromFile(io, writer, sl)) {
1165
1274
  if (sl.column > 0) {
1166
1275
  // The caret already takes one char
@@ -1468,12 +1577,12 @@ fn handleSegfaultPosix(sig: posix.SIG, info: *const posix.siginfo_t, ctx_ptr: ?*
1468
1577
  .tvos,
1469
1578
  .visionos,
1470
1579
  .watchos,
1580
+ .haiku,
1471
1581
  => @intFromPtr(info.addr),
1472
1582
  .linux,
1473
1583
  => @intFromPtr(info.fields.sigfault.addr),
1474
1584
  .netbsd,
1475
1585
  => @intFromPtr(info.info.reason.fault.addr),
1476
- .haiku,
1477
1586
  .openbsd,
1478
1587
  => @intFromPtr(info.data.fault.addr),
1479
1588
  .illumos,
@@ -1599,7 +1708,12 @@ test "manage resources correctly" {
1599
1708
  var di: SelfInfo = .init;
1600
1709
  defer di.deinit(io);
1601
1710
  const t: Io.Terminal = .{ .writer = &discarding.writer, .mode = .no_color };
1602
- try printSourceAtAddress(io, &di, t, S.showMyTrace());
1711
+ var text_arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
1712
+ defer text_arena.deinit();
1713
+ try printSourceAtAddress(io, &text_arena, &di, t, .{
1714
+ .address = S.showMyTrace(),
1715
+ .resolve_inline_callers = true,
1716
+ });
1603
1717
  }
1604
1718
 
1605
1719
  /// This API helps you track where a value originated and where it was mutated,
@@ -1648,8 +1762,8 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
1648
1762
  t.notes[t.index] = note;
1649
1763
  const addrs = &t.addrs[t.index];
1650
1764
  const st = captureCurrentStackTrace(.{ .first_address = addr }, addrs);
1651
- if (st.index < addrs.len) {
1652
- @memset(addrs[st.index..], 0); // zero unused frames to indicate end of trace
1765
+ if (st.return_addresses.len < addrs.len) {
1766
+ @memset(addrs[st.return_addresses.len..], 0); // zero unused frames to indicate end of trace
1653
1767
  }
1654
1768
  }
1655
1769
  // Keep counting even if the end is reached so that the
@@ -1667,9 +1781,10 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
1667
1781
  stderr.writer.print("{s}:\n", .{t.notes[i]}) catch return;
1668
1782
  var frames_array_mutable = frames_array;
1669
1783
  const frames = mem.sliceTo(frames_array_mutable[0..], 0);
1784
+ const len = @min(t.index, frames.len);
1670
1785
  const stack_trace: StackTrace = .{
1671
- .index = frames.len,
1672
- .instruction_addresses = frames,
1786
+ .return_addresses = frames[0..len],
1787
+ .skipped = if (len < frames.len) .none else .unknown,
1673
1788
  };
1674
1789
  writeStackTrace(&stack_trace, stderr) catch return;
1675
1790
  }
package/std/enums.zig CHANGED
@@ -252,7 +252,7 @@ pub fn EnumSet(comptime E: type) type {
252
252
  /// The maximum number of items in this set.
253
253
  pub const len = Indexer.count;
254
254
 
255
- bits: BitSet = BitSet.initEmpty(),
255
+ bits: BitSet = .empty,
256
256
 
257
257
  /// Initializes the set using a struct of bools
258
258
  pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
@@ -278,19 +278,27 @@ pub fn EnumSet(comptime E: type) type {
278
278
  return result;
279
279
  }
280
280
 
281
+ /// A set containing no keys.
282
+ pub const empty: Self = .{ .bits = .empty };
283
+
284
+ /// A set containing all possible keys.
285
+ pub const full: Self = .{ .bits = .full };
286
+
287
+ /// Deprecated: use `.empty`.
281
288
  /// Returns a set containing no keys.
282
289
  pub fn initEmpty() Self {
283
- return .{ .bits = BitSet.initEmpty() };
290
+ return .empty;
284
291
  }
285
292
 
293
+ /// Deprecated: use `.full`.
286
294
  /// Returns a set containing all possible keys.
287
295
  pub fn initFull() Self {
288
- return .{ .bits = BitSet.initFull() };
296
+ return .full;
289
297
  }
290
298
 
291
299
  /// Returns a set containing multiple keys.
292
300
  pub fn initMany(keys: []const Key) Self {
293
- var set = initEmpty();
301
+ var set: Self = .empty;
294
302
  for (keys) |key| set.insert(key);
295
303
  return set;
296
304
  }
@@ -440,7 +448,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
440
448
  const BitSet = std.StaticBitSet(Indexer.count);
441
449
 
442
450
  /// Bits determining whether items are in the map
443
- bits: BitSet = BitSet.initEmpty(),
451
+ bits: BitSet = .empty,
444
452
  /// Values of items in the map. If the associated
445
453
  /// bit is zero, the value is undefined.
446
454
  values: [Indexer.count]Value = undefined,
@@ -475,7 +483,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
475
483
  /// Consider using EnumArray instead if the map will remain full.
476
484
  pub fn initFull(value: Value) Self {
477
485
  var result: Self = .{
478
- .bits = Self.BitSet.initFull(),
486
+ .bits = .full,
479
487
  .values = undefined,
480
488
  };
481
489
  @memset(&result.values, value);
@@ -493,7 +501,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
493
501
  pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
494
502
  @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
495
503
  var result: Self = .{
496
- .bits = Self.BitSet.initFull(),
504
+ .bits = .full,
497
505
  .values = undefined,
498
506
  };
499
507
  inline for (0..Self.len) |i| {
@@ -687,16 +695,14 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
687
695
  return self;
688
696
  }
689
697
 
690
- /// Initializes the multiset with a count of zero.
691
- pub fn initEmpty() Self {
692
- return initWithCount(0);
693
- }
698
+ /// A multiset with a count of zero.
699
+ pub const empty: Self = .initWithCount(0);
694
700
 
695
701
  /// Initializes the multiset with all keys at the
696
702
  /// same count.
697
703
  pub fn initWithCount(comptime c: CountSize) Self {
698
704
  return .{
699
- .counts = EnumArray(E, CountSize).initDefault(c, .{}),
705
+ .counts = .initDefault(c, .{}),
700
706
  };
701
707
  }
702
708
 
@@ -855,7 +861,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
855
861
  test EnumMultiset {
856
862
  const Ball = enum { red, green, blue };
857
863
 
858
- const empty = EnumMultiset(Ball).initEmpty();
864
+ const empty = EnumMultiset(Ball).empty;
859
865
  const r0_g1_b2 = EnumMultiset(Ball).init(.{
860
866
  .red = 0,
861
867
  .green = 1,
@@ -1162,8 +1168,8 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
1162
1168
  test "pure EnumSet fns" {
1163
1169
  const Suit = enum { spades, hearts, clubs, diamonds };
1164
1170
 
1165
- const empty = EnumSet(Suit).initEmpty();
1166
- const full = EnumSet(Suit).initFull();
1171
+ const empty = EnumSet(Suit).empty;
1172
+ const full = EnumSet(Suit).full;
1167
1173
  const black = EnumSet(Suit).initMany(&[_]Suit{ .spades, .clubs });
1168
1174
  const red = EnumSet(Suit).initMany(&[_]Suit{ .hearts, .diamonds });
1169
1175
 
@@ -1224,8 +1230,8 @@ test "pure EnumSet fns" {
1224
1230
 
1225
1231
  test "EnumSet empty" {
1226
1232
  const E = enum {};
1227
- const empty = EnumSet(E).initEmpty();
1228
- const full = EnumSet(E).initFull();
1233
+ const empty = EnumSet(E).empty;
1234
+ const full = EnumSet(E).full;
1229
1235
 
1230
1236
  try std.testing.expect(empty.eql(full));
1231
1237
  try std.testing.expect(empty.complement().eql(full));
@@ -1236,13 +1242,13 @@ test "EnumSet empty" {
1236
1242
  test "EnumSet const iterator" {
1237
1243
  const Direction = enum { up, down, left, right };
1238
1244
  const diag_move = init: {
1239
- var move = EnumSet(Direction).initEmpty();
1245
+ var move = EnumSet(Direction).empty;
1240
1246
  move.insert(.right);
1241
1247
  move.insert(.up);
1242
1248
  break :init move;
1243
1249
  };
1244
1250
 
1245
- var result = EnumSet(Direction).initEmpty();
1251
+ var result = EnumSet(Direction).empty;
1246
1252
  var it = diag_move.iterator();
1247
1253
  while (it.next()) |dir| {
1248
1254
  result.insert(dir);
package/std/fmt.zig CHANGED
@@ -542,7 +542,7 @@ pub fn parseIntSizeSuffix(buf: []const u8, digit_base: u8) ParseIntError!usize {
542
542
  }
543
543
  const multiplier = math.powi(usize, magnitude_base, orders_of_magnitude) catch |err| switch (err) {
544
544
  error.Underflow => unreachable,
545
- error.Overflow => return error.Overflow,
545
+ error.Overflow => |e| return e,
546
546
  };
547
547
  const number = try std.fmt.parseInt(usize, without_suffix, digit_base);
548
548
  return math.mul(usize, number, multiplier);
@@ -1342,9 +1342,9 @@ pub const hex_charset = "0123456789abcdef";
1342
1342
 
1343
1343
  /// Converts an unsigned integer of any multiple of u8 to an array of lowercase
1344
1344
  /// hex bytes, little endian.
1345
- pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 {
1345
+ pub fn hex(x: anytype) [@typeInfo(@TypeOf(x)).int.bits / 4]u8 {
1346
1346
  comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned);
1347
- var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined;
1347
+ var result: [@typeInfo(@TypeOf(x)).int.bits / 4]u8 = undefined;
1348
1348
  var i: usize = 0;
1349
1349
  while (i < result.len / 2) : (i += 1) {
1350
1350
  const byte: u8 = @truncate(x >> @intCast(8 * i));
@@ -1360,6 +1360,11 @@ test hex {
1360
1360
  try std.testing.expect(x.len == 8);
1361
1361
  try std.testing.expectEqualStrings("efbeadde", &x);
1362
1362
  }
1363
+ {
1364
+ const s = "[" ++ hex(@as(u48, 0x12345678_abcd)) ++ "]";
1365
+ try std.testing.expect(s.len == 14);
1366
+ try std.testing.expectEqualStrings("[cdab78563412]", s);
1367
+ }
1363
1368
  {
1364
1369
  const s = "[" ++ hex(@as(u64, 0x12345678_abcdef00)) ++ "]";
1365
1370
  try std.testing.expect(s.len == 18);
package/std/fs/path.zig CHANGED
@@ -894,8 +894,9 @@ pub fn resolve(allocator: Allocator, paths: []const []const u8) Allocator.Error!
894
894
  pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator.Error![]u8 {
895
895
  // Avoid heap allocation when paths.len is <= @bitSizeOf(usize) * 2
896
896
  // (we use `* 3` because stackFallback uses 1 usize as a length)
897
- var bit_set_allocator_state = std.heap.stackFallback(@sizeOf(usize) * 3, allocator);
898
- const bit_set_allocator = bit_set_allocator_state.get();
897
+ var buf: [3]usize = undefined;
898
+ var bit_set_allocator_state: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), allocator);
899
+ const bit_set_allocator = bit_set_allocator_state.allocator();
899
900
  var relevant_paths = try std.bit_set.DynamicBitSetUnmanaged.initEmpty(bit_set_allocator, paths.len);
900
901
  defer relevant_paths.deinit(bit_set_allocator);
901
902
 
@@ -1642,7 +1643,8 @@ fn windowsResolveAgainstCwd(
1642
1643
  parsed: WindowsPath2(u8),
1643
1644
  ) ![]u8 {
1644
1645
  // Space for 256 WTF-16 code units; potentially 3 WTF-8 bytes per WTF-16 code unit
1645
- var temp_allocator_state = std.heap.stackFallback(256 * 3, gpa);
1646
+ var buf: [256 * 3]u8 = undefined;
1647
+ var temp_allocator_state: std.heap.BufferFirstAllocator = .init(&buf, gpa);
1646
1648
  return switch (parsed.kind) {
1647
1649
  .drive_absolute,
1648
1650
  .unc_absolute,
@@ -1668,7 +1670,7 @@ fn windowsResolveAgainstCwd(
1668
1670
  }
1669
1671
  },
1670
1672
  .drive_relative => blk: {
1671
- const temp_allocator = temp_allocator_state.get();
1673
+ const temp_allocator = temp_allocator_state.allocator();
1672
1674
  const drive_cwd = drive_cwd: {
1673
1675
  const parsed_cwd = parsePathWindows(u8, cwd);
1674
1676