@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.
- package/LICENSE +19 -0
- package/c/math.zig +135 -35
- package/c/stropts.zig +17 -0
- package/c.zig +1 -0
- package/compiler/aro/aro/Attribute/names.zig +604 -589
- package/compiler/aro/aro/Attribute.zig +202 -116
- package/compiler/aro/aro/Builtins/common.zig +874 -863
- package/compiler/aro/aro/Builtins/eval.zig +15 -7
- package/compiler/aro/aro/Builtins.zig +0 -1
- package/compiler/aro/aro/CodeGen.zig +3 -1
- package/compiler/aro/aro/Compilation.zig +120 -97
- package/compiler/aro/aro/Diagnostics.zig +21 -17
- package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
- package/compiler/aro/aro/Driver.zig +124 -50
- package/compiler/aro/aro/LangOpts.zig +12 -2
- package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
- package/compiler/aro/aro/Parser.zig +336 -142
- package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
- package/compiler/aro/aro/Preprocessor.zig +127 -56
- package/compiler/aro/aro/Target.zig +17 -12
- package/compiler/aro/aro/Tokenizer.zig +31 -14
- package/compiler/aro/aro/Toolchain.zig +4 -7
- package/compiler/aro/aro/Tree.zig +178 -148
- package/compiler/aro/aro/TypeStore.zig +82 -24
- package/compiler/aro/aro/Value.zig +13 -17
- package/compiler/aro/aro/features.zig +1 -0
- package/compiler/aro/aro/pragmas/once.zig +0 -1
- package/compiler/aro/aro/record_layout.zig +3 -3
- package/compiler/aro/assembly_backend/x86_64.zig +3 -4
- package/compiler/aro/backend/Assembly.zig +1 -2
- package/compiler/aro/backend/Interner.zig +2 -2
- package/compiler/aro/backend/Ir.zig +100 -92
- package/compiler/aro/include/ptrcheck.h +49 -0
- package/compiler/aro/main.zig +26 -10
- package/compiler/build_runner.zig +1 -0
- package/compiler/objdump.zig +93 -0
- package/compiler/reduce.zig +5 -1
- package/compiler/resinator/compile.zig +2 -2
- package/compiler/resinator/main.zig +7 -1
- package/compiler/resinator/preprocess.zig +1 -3
- package/compiler/std-docs.zig +8 -1
- package/compiler/test_runner.zig +193 -61
- package/compiler/translate-c/MacroTranslator.zig +80 -11
- package/compiler/translate-c/PatternList.zig +1 -9
- package/compiler/translate-c/Scope.zig +43 -6
- package/compiler/translate-c/Translator.zig +364 -126
- package/compiler/translate-c/ast.zig +19 -11
- package/compiler/translate-c/main.zig +75 -16
- package/compiler_rt/cos.zig +141 -52
- package/compiler_rt/limb64.zig +266 -0
- package/compiler_rt/long_double.zig +37 -0
- package/compiler_rt/mulo.zig +6 -1
- package/compiler_rt/rem_pio2l.zig +173 -0
- package/compiler_rt/sin.zig +140 -55
- package/compiler_rt/sincos.zig +279 -72
- package/compiler_rt/tan.zig +118 -47
- package/compiler_rt/trig.zig +256 -6
- package/compiler_rt.zig +2 -0
- package/fuzzer.zig +855 -307
- package/libc/musl/src/math/pow.c +343 -0
- package/package.json +1 -1
- package/std/Build/Fuzz.zig +6 -19
- package/std/Build/Module.zig +1 -1
- package/std/Build/Step/CheckObject.zig +3 -3
- package/std/Build/Step/Compile.zig +18 -0
- package/std/Build/Step/ConfigHeader.zig +49 -33
- package/std/Build/Step/InstallArtifact.zig +18 -0
- package/std/Build/Step/Run.zig +536 -87
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/Step.zig +8 -15
- package/std/Build/WebServer.zig +29 -17
- package/std/Build/abi.zig +47 -11
- package/std/Build.zig +17 -14
- package/std/Io/Dispatch.zig +2 -0
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/File.zig +1 -0
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io/Threaded.zig +181 -143
- package/std/Io/Uring.zig +2 -1
- package/std/Io.zig +970 -2
- package/std/Target.zig +3 -2
- package/std/Thread.zig +8 -3
- package/std/array_hash_map.zig +96 -555
- package/std/array_list.zig +22 -31
- package/std/bit_set.zig +22 -6
- package/std/builtin/assembly.zig +68 -0
- package/std/c.zig +17 -17
- package/std/compress/flate/Compress.zig +3 -3
- package/std/crypto/Certificate/Bundle.zig +15 -1
- package/std/crypto/codecs/asn1.zig +33 -18
- package/std/crypto/codecs/base64_hex_ct.zig +14 -4
- package/std/debug/Dwarf.zig +29 -9
- package/std/debug/Info.zig +4 -0
- package/std/debug/MachOFile.zig +46 -8
- package/std/debug/Pdb.zig +539 -36
- package/std/debug/SelfInfo/Elf.zig +19 -18
- package/std/debug/SelfInfo/MachO.zig +18 -7
- package/std/debug/SelfInfo/Windows.zig +138 -36
- package/std/debug.zig +179 -65
- package/std/enums.zig +25 -19
- package/std/heap/ArenaAllocator.zig +145 -154
- package/std/heap/debug_allocator.zig +7 -7
- package/std/http/Client.zig +10 -6
- package/std/http.zig +11 -9
- package/std/json/Stringify.zig +3 -3
- package/std/json/dynamic.zig +4 -4
- package/std/math/big/int.zig +16 -17
- package/std/mem/Allocator.zig +4 -5
- package/std/mem.zig +48 -0
- package/std/os/emscripten.zig +1 -17
- package/std/os/linux.zig +7 -2
- package/std/os/windows.zig +2 -2
- package/std/pdb.zig +143 -4
- package/std/posix.zig +6 -12
- package/std/priority_dequeue.zig +13 -12
- package/std/priority_queue.zig +5 -4
- package/std/process/Child.zig +1 -1
- package/std/process/Environ.zig +1 -1
- package/std/start.zig +17 -4
- package/std/std.zig +19 -6
- package/std/testing/FailingAllocator.zig +4 -4
- package/std/testing/Smith.zig +37 -2
- package/std/zig/Ast/Render.zig +186 -458
- package/std/zig/Ast.zig +0 -4
- package/std/zig/AstGen.zig +44 -7
- package/std/zig/AstSmith.zig +2602 -0
- package/std/zig/Client.zig +8 -3
- package/std/zig/Parse.zig +83 -74
- package/std/zig/Server.zig +26 -0
- package/std/zig/Zir.zig +17 -0
- package/std/zig/c_translation/helpers.zig +14 -9
- package/std/zig/llvm/Builder.zig +107 -48
- package/std/zig/system.zig +20 -4
- package/std/zig/tokenizer.zig +2 -1
- package/std/zig.zig +6 -0
- package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
- package/libc/mingw/complex/cabs.c +0 -48
- package/libc/mingw/complex/cabsf.c +0 -48
- package/libc/mingw/complex/cacos.c +0 -50
- package/libc/mingw/complex/cacosf.c +0 -50
- package/libc/mingw/complex/carg.c +0 -48
- package/libc/mingw/complex/cargf.c +0 -48
- package/libc/mingw/complex/casin.c +0 -50
- package/libc/mingw/complex/casinf.c +0 -50
- package/libc/mingw/complex/catan.c +0 -50
- package/libc/mingw/complex/catanf.c +0 -50
- package/libc/mingw/complex/ccos.c +0 -50
- package/libc/mingw/complex/ccosf.c +0 -50
- package/libc/mingw/complex/cexp.c +0 -48
- package/libc/mingw/complex/cexpf.c +0 -48
- package/libc/mingw/complex/cimag.c +0 -48
- package/libc/mingw/complex/cimagf.c +0 -48
- package/libc/mingw/complex/clog.c +0 -48
- package/libc/mingw/complex/clog10.c +0 -49
- package/libc/mingw/complex/clog10f.c +0 -49
- package/libc/mingw/complex/clogf.c +0 -48
- package/libc/mingw/complex/conj.c +0 -48
- package/libc/mingw/complex/conjf.c +0 -48
- package/libc/mingw/complex/cpow.c +0 -48
- package/libc/mingw/complex/cpowf.c +0 -48
- package/libc/mingw/complex/cproj.c +0 -48
- package/libc/mingw/complex/cprojf.c +0 -48
- package/libc/mingw/complex/creal.c +0 -48
- package/libc/mingw/complex/crealf.c +0 -48
- package/libc/mingw/complex/csin.c +0 -50
- package/libc/mingw/complex/csinf.c +0 -50
- package/libc/mingw/complex/csqrt.c +0 -48
- package/libc/mingw/complex/csqrtf.c +0 -48
- package/libc/mingw/complex/ctan.c +0 -50
- package/libc/mingw/complex/ctanf.c +0 -50
- package/libc/mingw/math/arm/s_rint.c +0 -86
- package/libc/mingw/math/arm/s_rintf.c +0 -51
- package/libc/mingw/math/arm/sincos.S +0 -30
- package/libc/mingw/math/arm-common/sincosl.c +0 -13
- package/libc/mingw/math/arm64/rint.c +0 -12
- package/libc/mingw/math/arm64/rintf.c +0 -12
- package/libc/mingw/math/arm64/sincos.S +0 -32
- package/libc/mingw/math/bsd_private_base.h +0 -148
- package/libc/mingw/math/frexpf.c +0 -13
- package/libc/mingw/math/frexpl.c +0 -71
- package/libc/mingw/math/x86/acosf.c +0 -29
- package/libc/mingw/math/x86/atanf.c +0 -23
- package/libc/mingw/math/x86/atanl.c +0 -18
- package/libc/mingw/math/x86/cos.def.h +0 -65
- package/libc/mingw/math/x86/cosl.c +0 -46
- package/libc/mingw/math/x86/cosl_internal.S +0 -55
- package/libc/mingw/math/x86/ldexp.c +0 -23
- package/libc/mingw/math/x86/scalbn.S +0 -41
- package/libc/mingw/math/x86/scalbnf.S +0 -40
- package/libc/mingw/math/x86/sin.def.h +0 -65
- package/libc/mingw/math/x86/sinl.c +0 -46
- package/libc/mingw/math/x86/sinl_internal.S +0 -58
- package/libc/mingw/math/x86/tanl.S +0 -62
- package/libc/mingw/misc/btowc.c +0 -28
- package/libc/mingw/misc/wcstof.c +0 -66
- package/libc/mingw/misc/wcstoimax.c +0 -132
- package/libc/mingw/misc/wcstoumax.c +0 -126
- package/libc/mingw/misc/wctob.c +0 -29
- package/libc/mingw/misc/winbs_uint64.c +0 -6
- package/libc/mingw/misc/winbs_ulong.c +0 -6
- package/libc/mingw/misc/winbs_ushort.c +0 -6
- package/libc/mingw/stdio/_Exit.c +0 -10
- package/libc/mingw/stdio/_findfirst64i32.c +0 -21
- package/libc/mingw/stdio/_findnext64i32.c +0 -21
- package/libc/mingw/stdio/_fstat64i32.c +0 -37
- package/libc/mingw/stdio/_stat64i32.c +0 -37
- package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
- package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
- package/libc/mingw/stdio/_wstat64i32.c +0 -37
- package/libc/musl/src/legacy/isastream.c +0 -7
- package/libc/musl/src/legacy/valloc.c +0 -8
- package/libc/musl/src/math/__cosl.c +0 -96
- package/libc/musl/src/math/__sinl.c +0 -78
- package/libc/musl/src/math/__tanl.c +0 -143
- package/libc/musl/src/math/aarch64/lrint.c +0 -10
- package/libc/musl/src/math/aarch64/lrintf.c +0 -10
- package/libc/musl/src/math/aarch64/rintf.c +0 -7
- package/libc/musl/src/math/cosl.c +0 -39
- package/libc/musl/src/math/fdim.c +0 -10
- package/libc/musl/src/math/finite.c +0 -7
- package/libc/musl/src/math/finitef.c +0 -7
- package/libc/musl/src/math/frexp.c +0 -23
- package/libc/musl/src/math/frexpf.c +0 -23
- package/libc/musl/src/math/frexpl.c +0 -29
- package/libc/musl/src/math/i386/lrint.c +0 -8
- package/libc/musl/src/math/i386/lrintf.c +0 -8
- package/libc/musl/src/math/i386/rintf.c +0 -7
- package/libc/musl/src/math/lrint.c +0 -72
- package/libc/musl/src/math/lrintf.c +0 -8
- package/libc/musl/src/math/powerpc64/lrint.c +0 -16
- package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
- package/libc/musl/src/math/rintf.c +0 -30
- package/libc/musl/src/math/s390x/rintf.c +0 -15
- package/libc/musl/src/math/sincosl.c +0 -60
- package/libc/musl/src/math/sinl.c +0 -41
- package/libc/musl/src/math/tanl.c +0 -29
- package/libc/musl/src/math/x32/lrint.s +0 -5
- package/libc/musl/src/math/x32/lrintf.s +0 -5
- package/libc/musl/src/math/x86_64/lrint.c +0 -8
- package/libc/musl/src/math/x86_64/lrintf.c +0 -8
- 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 ".");
|
package/std/Build/Step.zig
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
-
|
|
731
|
-
|
|
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(
|
package/std/Build/WebServer.zig
CHANGED
|
@@ -6,7 +6,7 @@ root_prog_node: std.Progress.Node,
|
|
|
6
6
|
watch: bool,
|
|
7
7
|
|
|
8
8
|
tcp_server: ?net.Server,
|
|
9
|
-
|
|
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
|
-
.
|
|
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.
|
|
139
|
+
if (ws.serve_task) |t| {
|
|
140
140
|
if (ws.tcp_server) |*s| s.stream.close(io);
|
|
141
|
-
t.
|
|
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.
|
|
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}: {
|
|
153
|
+
log.err("failed to listen to port {d}: {t}", .{ ws.listen_address.getPort(), err });
|
|
154
154
|
return error.AlreadyReported;
|
|
155
155
|
};
|
|
156
|
-
ws.
|
|
157
|
-
log.err("unable to spawn web server thread: {
|
|
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
|
-
|
|
173
|
-
|
|
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
|
-
|
|
176
|
-
log.err("unable to spawn connection thread: {
|
|
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
|
-
|
|
307
|
-
defer recv_thread.
|
|
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
|
|
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
|
|
167
|
-
|
|
168
|
-
|
|
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`
|
|
171
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
89
|
+
modules: std.array_hash_map.String(*Module),
|
|
90
90
|
|
|
91
|
-
named_writefiles: std.
|
|
92
|
-
named_lazy_paths: std.
|
|
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 = .
|
|
313
|
-
.named_writefiles = .
|
|
314
|
-
.named_lazy_paths = .
|
|
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 = .
|
|
406
|
-
.named_writefiles = .
|
|
407
|
-
.named_lazy_paths = .
|
|
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
|
-
.
|
|
1906
|
+
.unknown => |code| {
|
|
1904
1907
|
out_code.* = @as(u8, @truncate(code));
|
|
1905
1908
|
return error.ProcessTerminated;
|
|
1906
1909
|
},
|
package/std/Io/Dispatch.zig
CHANGED
|
@@ -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
|
}
|
package/std/Io/File/Reader.zig
CHANGED
|
@@ -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
|
|
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
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 = .
|
|
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 = .
|
|
716
|
+
.awaiting_completions = .empty,
|
|
717
717
|
};
|
|
718
718
|
closure.* = .{
|
|
719
719
|
.kqueue = k,
|