mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
libfuzzer: use a function pointer instead of extern
solves the problem presented in the previous commit message
This commit is contained in:
parent
892ce7ef52
commit
2b76221a46
@ -345,7 +345,7 @@ const FuzzerSlice = extern struct {
|
||||
|
||||
var is_fuzz_test: bool = undefined;
|
||||
|
||||
extern fn fuzzer_start() void;
|
||||
extern fn fuzzer_start(testOne: *const fn ([*]const u8, usize) callconv(.C) void) void;
|
||||
extern fn fuzzer_init(cache_dir: FuzzerSlice) void;
|
||||
extern fn fuzzer_coverage_id() u64;
|
||||
|
||||
@ -394,8 +394,7 @@ pub fn fuzz(
|
||||
}
|
||||
};
|
||||
if (builtin.fuzz) {
|
||||
@export(&global.fuzzer_one, .{ .name = "fuzzer_one" });
|
||||
fuzzer_start();
|
||||
fuzzer_start(&global.fuzzer_one);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -423,9 +423,10 @@ export fn fuzzer_coverage_id() u64 {
|
||||
return fuzzer.coverage_id;
|
||||
}
|
||||
|
||||
extern fn fuzzer_one(input_ptr: [*]const u8, input_len: usize) callconv(.C) void;
|
||||
var fuzzer_one: *const fn (input_ptr: [*]const u8, input_len: usize) callconv(.C) void = undefined;
|
||||
|
||||
export fn fuzzer_start() void {
|
||||
export fn fuzzer_start(testOne: @TypeOf(fuzzer_one)) void {
|
||||
fuzzer_one = testOne;
|
||||
fuzzer.start() catch |err| switch (err) {
|
||||
error.OutOfMemory => fatal("out of memory", .{}),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user