@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
@@ -18,14 +18,12 @@ target: std.Build.ResolvedTarget,
18
18
  optimize: std.builtin.OptimizeMode,
19
19
  output_file: std.Build.GeneratedFile,
20
20
  link_libc: bool,
21
- use_clang: bool,
22
21
 
23
22
  pub const Options = struct {
24
23
  root_source_file: std.Build.LazyPath,
25
24
  target: std.Build.ResolvedTarget,
26
25
  optimize: std.builtin.OptimizeMode,
27
26
  link_libc: bool = true,
28
- use_clang: bool = true,
29
27
  };
30
28
 
31
29
  pub fn create(owner: *std.Build, options: Options) *TranslateC {
@@ -46,7 +44,6 @@ pub fn create(owner: *std.Build, options: Options) *TranslateC {
46
44
  .optimize = options.optimize,
47
45
  .output_file = .{ .step = &translate_c.step },
48
46
  .link_libc = options.link_libc,
49
- .use_clang = options.use_clang,
50
47
  .system_libs = .empty,
51
48
  };
52
49
  source.addStepDependencies(&translate_c.step);
@@ -175,9 +172,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
175
172
  if (translate_c.link_libc) {
176
173
  try argv_list.append("-lc");
177
174
  }
178
- if (!translate_c.use_clang) {
179
- try argv_list.append("-fno-clang");
180
- }
181
175
 
182
176
  try argv_list.append("--cache-dir");
183
177
  try argv_list.append(b.cache_root.path orelse ".");
@@ -67,7 +67,7 @@ test_results: TestResults,
67
67
 
68
68
  /// The return address associated with creation of this step that can be useful
69
69
  /// to print along with debugging messages.
70
- debug_stack_trace: std.builtin.StackTrace,
70
+ debug_stack_trace: std.debug.StackTrace,
71
71
 
72
72
  pub const TestResults = struct {
73
73
  /// The total number of tests in the step. Every test has a "status" from the following:
@@ -328,7 +328,7 @@ pub fn cast(step: *Step, comptime T: type) ?*T {
328
328
  /// For debugging purposes, prints identifying information about this Step.
329
329
  pub fn dump(step: *Step, t: Io.Terminal) void {
330
330
  const w = t.writer;
331
- if (step.debug_stack_trace.instruction_addresses.len > 0) {
331
+ if (step.debug_stack_trace.return_addresses.len > 0) {
332
332
  w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};
333
333
  std.debug.writeStackTrace(&step.debug_stack_trace, t) catch {};
334
334
  } else {
@@ -725,19 +725,12 @@ pub inline fn handleChildProcUnsupported(s: *Step) error{ OutOfMemory, MakeFaile
725
725
  /// Asserts that the caller has already populated `s.result_failed_command`.
726
726
  pub fn handleChildProcessTerm(s: *Step, term: std.process.Child.Term) error{ MakeFailed, OutOfMemory }!void {
727
727
  assert(s.result_failed_command != null);
728
- switch (term) {
729
- .exited => |code| {
730
- if (code != 0) {
731
- return s.fail("process exited with error code {d}", .{code});
732
- }
733
- },
734
- .signal => |sig| {
735
- return s.fail("process terminated with signal {t}", .{sig});
736
- },
737
- .stopped, .unknown => {
738
- return s.fail("process terminated unexpectedly", .{});
739
- },
740
- }
728
+ return switch (term) {
729
+ .exited => |code| if (code != 0) s.fail("process exited with error code {d}", .{code}),
730
+ .signal => |sig| s.fail("process terminated with signal {t}", .{sig}),
731
+ .stopped => |sig| s.fail("process stopped with signal {t}", .{sig}),
732
+ .unknown => s.fail("process terminated unexpectedly", .{}),
733
+ };
741
734
  }
742
735
 
743
736
  pub fn allocPrintCmd(
@@ -6,7 +6,7 @@ root_prog_node: std.Progress.Node,
6
6
  watch: bool,
7
7
 
8
8
  tcp_server: ?net.Server,
9
- serve_thread: ?std.Thread,
9
+ serve_task: ?Io.Future(Io.Cancelable!void),
10
10
 
11
11
  /// Uses `Io.Clock.awake`.
12
12
  base_timestamp: Io.Timestamp,
@@ -103,7 +103,7 @@ pub fn init(opts: Options) WebServer {
103
103
  .watch = opts.watch,
104
104
 
105
105
  .tcp_server = null,
106
- .serve_thread = null,
106
+ .serve_task = null,
107
107
 
108
108
  .base_timestamp = opts.base_timestamp.raw,
109
109
  .step_names_trailing = step_names_trailing,
@@ -136,9 +136,9 @@ pub fn deinit(ws: *WebServer) void {
136
136
  gpa.free(ws.time_report_msgs);
137
137
  gpa.free(ws.time_report_update_times);
138
138
 
139
- if (ws.serve_thread) |t| {
139
+ if (ws.serve_task) |t| {
140
140
  if (ws.tcp_server) |*s| s.stream.close(io);
141
- t.join();
141
+ t.await();
142
142
  }
143
143
  if (ws.tcp_server) |*s| s.deinit();
144
144
 
@@ -146,15 +146,15 @@ pub fn deinit(ws: *WebServer) void {
146
146
  }
147
147
  pub fn start(ws: *WebServer) error{AlreadyReported}!void {
148
148
  assert(ws.tcp_server == null);
149
- assert(ws.serve_thread == null);
149
+ assert(ws.serve_task == null);
150
150
  const io = ws.graph.io;
151
151
 
152
152
  ws.tcp_server = ws.listen_address.listen(io, .{ .reuse_address = true }) catch |err| {
153
- log.err("failed to listen to port {d}: {s}", .{ ws.listen_address.getPort(), @errorName(err) });
153
+ log.err("failed to listen to port {d}: {t}", .{ ws.listen_address.getPort(), err });
154
154
  return error.AlreadyReported;
155
155
  };
156
- ws.serve_thread = std.Thread.spawn(.{}, serve, .{ws}) catch |err| {
157
- log.err("unable to spawn web server thread: {s}", .{@errorName(err)});
156
+ ws.serve_task = io.concurrent(serve, .{ws}) catch |err| {
157
+ log.err("unable to spawn web server thread: {t}", .{err});
158
158
  ws.tcp_server.?.deinit(io);
159
159
  ws.tcp_server = null;
160
160
  return error.AlreadyReported;
@@ -165,15 +165,20 @@ pub fn start(ws: *WebServer) error{AlreadyReported}!void {
165
165
  log.info("hint: pass '--webui={f}' to use the same port next time", .{ws.tcp_server.?.socket.address});
166
166
  }
167
167
  }
168
- fn serve(ws: *WebServer) void {
168
+ fn serve(ws: *WebServer) Io.Cancelable!void {
169
169
  const io = ws.graph.io;
170
+ var group: Io.Group = .init;
171
+ defer group.cancel(io);
170
172
  while (true) {
171
- var stream = ws.tcp_server.?.accept(io) catch |err| {
172
- log.err("failed to accept connection: {s}", .{@errorName(err)});
173
- return;
173
+ var stream = ws.tcp_server.?.accept(io) catch |err| switch (err) {
174
+ error.Canceled => |e| return e,
175
+ else => |e| {
176
+ log.err("failed to accept connection: {t}", .{e});
177
+ return;
178
+ },
174
179
  };
175
- _ = std.Thread.spawn(.{}, accept, .{ ws, stream }) catch |err| {
176
- log.err("unable to spawn connection thread: {s}", .{@errorName(err)});
180
+ group.concurrent(io, accept, .{ ws, stream }) catch |err| {
181
+ log.err("unable to spawn connection thread: {t}", .{err});
177
182
  stream.close(io);
178
183
  continue;
179
184
  };
@@ -303,8 +308,8 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn {
303
308
  copy.* = @atomicLoad(u8, shared, .monotonic);
304
309
  }
305
310
 
306
- const recv_thread = try std.Thread.spawn(.{}, recvWebSocketMessages, .{ ws, sock });
307
- defer recv_thread.join();
311
+ var recv_thread = try io.concurrent(recvWebSocketMessages, .{ ws, sock });
312
+ defer recv_thread.cancel(io);
308
313
 
309
314
  {
310
315
  const hello_header: abi.Hello = .{
@@ -676,7 +681,14 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
676
681
  );
677
682
  return error.WasmCompilationFailed;
678
683
  },
679
- .stopped, .unknown => {
684
+ .stopped => |sig| {
685
+ log.err(
686
+ "the following command stopped unexpectedly with signal {t}:\n{s}",
687
+ .{ sig, try Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) },
688
+ );
689
+ return error.WasmCompilationFailed;
690
+ },
691
+ .unknown => {
680
692
  log.err(
681
693
  "the following command terminated unexpectedly:\n{s}",
682
694
  .{try Build.Step.allocPrintCmd(arena, .inherit, null, argv.items)},
package/std/Build/abi.zig CHANGED
@@ -162,15 +162,39 @@ pub const fuzz = struct {
162
162
  pub extern fn fuzzer_init(cache_dir_path: Slice) void;
163
163
  /// `fuzzer_init` must be called first.
164
164
  pub extern fn fuzzer_coverage() Coverage;
165
+ pub extern fn fuzzer_unslide_address(addr: usize) usize;
166
+
167
+ /// Performs all the fuzzing work and selects tests to run
168
+ ///
165
169
  /// `fuzzer_init` must be called first.
166
- pub extern fn fuzzer_set_test(test_one: TestOne, unit_test_name: Slice) void;
167
- /// `fuzzer_set_test` must be called first.
168
- /// The callee owns the memory of bytes and must not free it until `fuzzer_main` returns
170
+ pub extern fn fuzzer_main(
171
+ n_tests: u32,
172
+ seed: u32,
173
+ limit_kind: LimitKind,
174
+ amount_or_instance: u64,
175
+ ) void;
176
+ pub extern fn runner_test_run(i: u32) void;
177
+ pub extern fn runner_test_name(i: u32) Slice;
178
+ // Since the runner owns the `std.zig.Server` instance, it also controls the
179
+ // concurrent Io instance so reads can be canceled. As such, the fuzzer has
180
+ // to call into the runner for any zig server / concurrent operation.
181
+ pub extern fn runner_start_input_poller() void;
182
+ pub extern fn runner_stop_input_poller() void;
183
+ /// Returns if cancelation has been indicated.
184
+ pub extern fn runner_futex_wait(*const u32, expected: u32) bool;
185
+ pub extern fn runner_futex_wake(*const u32, waiters: u32) void;
186
+ pub extern fn runner_broadcast_input(test_i: u32, bytes: Slice) void;
187
+ /// `fuzzer_main` must be called first.
188
+ ///
189
+ /// Called concurrently with `fuzzer_main`. Returns if cancelation has been indicated.
190
+ pub extern fn fuzzer_receive_input(test_i: u32, bytes: Slice) bool;
191
+
192
+ /// Must be called from inside a test function
193
+ pub extern fn fuzzer_set_test(test_one: TestOne) void;
194
+ /// Must be called from inside a test function where `fuzzer_set_test` has been called first.
169
195
  pub extern fn fuzzer_new_input(bytes: Slice) void;
170
- /// `fuzzer_set_test` must be called first.
171
- /// Resets the fuzzer's state to that of `fuzzer_init`.
172
- pub extern fn fuzzer_main(limit_kind: LimitKind, amount: u64) void;
173
- pub extern fn fuzzer_unslide_address(addr: usize) usize;
196
+ /// Must be called from inside a test function where `fuzzer_set_test` has been called first.
197
+ pub extern fn fuzzer_start_test() void;
174
198
 
175
199
  pub extern fn fuzzer_int(uid: Uid, weights: Weights) u64;
176
200
  pub extern fn fuzzer_eos(uid: Uid, weights: Weights) bool;
@@ -235,7 +259,8 @@ pub const fuzz = struct {
235
259
  max: u64,
236
260
  weight: u64,
237
261
 
238
- fn intFromValue(x: anytype) u64 {
262
+ /// `inline` to propogate comptimeness
263
+ inline fn intFromValue(x: anytype) u64 {
239
264
  const T = @TypeOf(x);
240
265
  return switch (@typeInfo(T)) {
241
266
  .comptime_int => x,
@@ -269,11 +294,13 @@ pub const fuzz = struct {
269
294
  };
270
295
  }
271
296
 
272
- pub fn value(T: type, x: T, weight: u64) Weight {
297
+ /// `inline` to propogate comptimeness
298
+ pub inline fn value(T: type, x: T, weight: u64) Weight {
273
299
  return .{ .min = intFromValue(x), .max = intFromValue(x), .weight = weight };
274
300
  }
275
301
 
276
- pub fn rangeAtMost(T: type, at_least: T, at_most: T, weight: u64) Weight {
302
+ /// `inline` to propogate comptimeness
303
+ pub inline fn rangeAtMost(T: type, at_least: T, at_most: T, weight: u64) Weight {
277
304
  std.debug.assert(intFromValue(at_least) <= intFromValue(at_most));
278
305
  return .{
279
306
  .min = intFromValue(at_least),
@@ -282,7 +309,8 @@ pub const fuzz = struct {
282
309
  };
283
310
  }
284
311
 
285
- pub fn rangeLessThan(T: type, at_least: T, less_than: T, weight: u64) Weight {
312
+ /// `inline` to propogate comptimeness
313
+ pub inline fn rangeLessThan(T: type, at_least: T, less_than: T, weight: u64) Weight {
286
314
  std.debug.assert(intFromValue(at_least) < intFromValue(less_than));
287
315
  return .{
288
316
  .min = intFromValue(at_least),
@@ -333,6 +361,14 @@ pub const fuzz = struct {
333
361
  }
334
362
  };
335
363
 
364
+ /// Fields are little-endian
365
+ pub const MmapInputHeader = extern struct {
366
+ pc_digest: u64 align(4), // aligned so header does not have padding
367
+ instance_id: u32,
368
+ test_i: u32,
369
+ len: u32,
370
+ };
371
+
336
372
  /// WebSocket server->client.
337
373
  ///
338
374
  /// Sent once, when fuzzing starts, to indicate the available coverage data.
package/std/Build.zig CHANGED
@@ -86,10 +86,10 @@ libc_runtimes_dir: ?[]const u8 = null,
86
86
 
87
87
  dep_prefix: []const u8 = "",
88
88
 
89
- modules: std.StringArrayHashMap(*Module),
89
+ modules: std.array_hash_map.String(*Module),
90
90
 
91
- named_writefiles: std.StringArrayHashMap(*Step.WriteFile),
92
- named_lazy_paths: std.StringArrayHashMap(LazyPath),
91
+ named_writefiles: std.array_hash_map.String(*Step.WriteFile),
92
+ named_lazy_paths: std.array_hash_map.String(LazyPath),
93
93
  /// The hash of this instance's package. `""` means that this is the root package.
94
94
  pkg_hash: []const u8,
95
95
  /// A mapping from dependency names to package hashes.
@@ -128,6 +128,9 @@ pub const Graph = struct {
128
128
  random_seed: u32 = 0,
129
129
  dependency_cache: InitializedDepMap = .empty,
130
130
  allow_so_scripts: ?bool = null,
131
+ /// Steps should use `io` to limit the number of jobs, however in the case of
132
+ /// a single step spawning a fixed number of processes this can be used.
133
+ max_jobs: ?u32 = null,
131
134
  time_report: bool,
132
135
  /// Similar to the `Io.Terminal.Mode` returned by `Io.lockStderr`, but also
133
136
  /// respects the '--color' flag.
@@ -309,9 +312,9 @@ pub fn create(
309
312
  },
310
313
  .install_path = undefined,
311
314
  .args = null,
312
- .modules = .init(arena),
313
- .named_writefiles = .init(arena),
314
- .named_lazy_paths = .init(arena),
315
+ .modules = .empty,
316
+ .named_writefiles = .empty,
317
+ .named_lazy_paths = .empty,
315
318
  .pkg_hash = "",
316
319
  .available_deps = available_deps,
317
320
  .release_mode = .off,
@@ -402,9 +405,9 @@ fn createChildOnly(
402
405
  .enable_wine = parent.enable_wine,
403
406
  .libc_runtimes_dir = parent.libc_runtimes_dir,
404
407
  .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
405
- .modules = .init(allocator),
406
- .named_writefiles = .init(allocator),
407
- .named_lazy_paths = .init(allocator),
408
+ .modules = .empty,
409
+ .named_writefiles = .empty,
410
+ .named_lazy_paths = .empty,
408
411
  .pkg_hash = pkg_hash,
409
412
  .available_deps = pkg_deps,
410
413
  .release_mode = parent.release_mode,
@@ -905,7 +908,7 @@ pub const AssemblyOptions = struct {
905
908
  /// `createModule` can be used instead to create a private module.
906
909
  pub fn addModule(b: *Build, name: []const u8, options: Module.CreateOptions) *Module {
907
910
  const module = Module.create(b, options);
908
- b.modules.put(b.dupe(name), module) catch @panic("OOM");
911
+ b.modules.put(b.graph.arena, b.dupe(name), module) catch @panic("OOM");
909
912
  return module;
910
913
  }
911
914
 
@@ -1053,12 +1056,12 @@ pub fn addWriteFile(b: *Build, file_path: []const u8, data: []const u8) *Step.Wr
1053
1056
 
1054
1057
  pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile {
1055
1058
  const wf = Step.WriteFile.create(b);
1056
- b.named_writefiles.put(b.dupe(name), wf) catch @panic("OOM");
1059
+ b.named_writefiles.put(b.graph.arena, b.dupe(name), wf) catch @panic("OOM");
1057
1060
  return wf;
1058
1061
  }
1059
1062
 
1060
1063
  pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void {
1061
- b.named_lazy_paths.put(b.dupe(name), lp.dupe(b)) catch @panic("OOM");
1064
+ b.named_lazy_paths.put(b.graph.arena, b.dupe(name), lp.dupe(b)) catch @panic("OOM");
1062
1065
  }
1063
1066
 
1064
1067
  /// Creates a step for mutating files inside a temporary directory created lazily
@@ -1896,11 +1899,11 @@ pub fn runAllowFail(
1896
1899
  }
1897
1900
  return stdout;
1898
1901
  },
1899
- .signal => |sig| {
1902
+ .signal, .stopped => |sig| {
1900
1903
  out_code.* = @as(u8, @truncate(@intFromEnum(sig)));
1901
1904
  return error.ProcessTerminated;
1902
1905
  },
1903
- .stopped, .unknown => |code| {
1906
+ .unknown => |code| {
1904
1907
  out_code.* = @as(u8, @truncate(code));
1905
1908
  return error.ProcessTerminated;
1906
1909
  },
@@ -2512,6 +2512,7 @@ fn dirCreateFile(
2512
2512
  .OPNOTSUPP => return error.FileLocksUnsupported,
2513
2513
  .AGAIN => return error.WouldBlock,
2514
2514
  .TXTBSY => return error.FileBusy,
2515
+ .ROFS => return error.ReadOnlyFileSystem,
2515
2516
  .NXIO => return error.NoDevice,
2516
2517
  .ILSEQ => return error.BadPathName,
2517
2518
  else => |err| return unexpectedErrno(err),
@@ -2647,6 +2648,7 @@ fn dirOpenFile(
2647
2648
  .AGAIN => return error.WouldBlock,
2648
2649
  .TXTBSY => return error.FileBusy,
2649
2650
  .NXIO => return error.NoDevice,
2651
+ .ROFS => return error.ReadOnlyFileSystem,
2650
2652
  .ILSEQ => return error.BadPathName,
2651
2653
  else => |err| return unexpectedErrno(err),
2652
2654
  }
@@ -309,7 +309,9 @@ fn discard(io_reader: *Io.Reader, limit: Io.Limit) Io.Reader.Error!usize {
309
309
  return 0;
310
310
  };
311
311
  const logical_pos = logicalPos(r);
312
- const delta = @min(@intFromEnum(limit), size - logical_pos);
312
+ const bytes_remaining = size - logical_pos;
313
+ if (bytes_remaining == 0) return error.EndOfStream;
314
+ const delta = @min(@intFromEnum(limit), bytes_remaining);
313
315
  setLogicalPos(r, logical_pos + delta);
314
316
  return delta;
315
317
  },
package/std/Io/File.zig CHANGED
@@ -202,6 +202,7 @@ pub const OpenError = error{
202
202
  NotDir,
203
203
  /// The path already exists and the `CREAT` and `EXCL` flags were provided.
204
204
  PathAlreadyExists,
205
+ ReadOnlyFileSystem,
205
206
  DeviceBusy,
206
207
  FileLocksUnsupported,
207
208
  /// One of these three things:
package/std/Io/Kqueue.zig CHANGED
@@ -186,7 +186,7 @@ pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
186
186
  .awaiter = null,
187
187
  .queue_next = null,
188
188
  .cancel_thread = null,
189
- .awaiting_completions = .initEmpty(),
189
+ .awaiting_completions = .empty,
190
190
  };
191
191
  const main_thread = &k.threads.allocated[0];
192
192
  Thread.self = main_thread;
@@ -713,7 +713,7 @@ fn concurrent(
713
713
  .awaiter = null,
714
714
  .queue_next = null,
715
715
  .cancel_thread = null,
716
- .awaiting_completions = .initEmpty(),
716
+ .awaiting_completions = .empty,
717
717
  };
718
718
  closure.* = .{
719
719
  .kqueue = k,