libfuzzer: use a function pointer instead of extern

solves the problem presented in the previous commit message
This commit is contained in:
Andrew Kelley 2024-09-09 19:57:31 -07:00
parent 892ce7ef52
commit 2b76221a46
2 changed files with 5 additions and 5 deletions

View File

@ -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;
}

View File

@ -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", .{}),
};