pub fn lookup(self: *DlDynLib, comptime T: type, name: [:0]const u8) ?T self: *DlDynLibT: typename: [:0]const u8577
578
579
580
581
582
583
584
585 pub fn lookup(self: *DlDynLib, comptime T: type, name: [:0]const u8) ?T {
// dlsym (and other dl-functions) secretly take shadow parameter - return address on stack
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826
if (@call(.never_tail, std.c.dlsym, .{ self.handle, name.ptr })) |symbol| {
return @as(T, @ptrCast(@alignCast(symbol)));
} else {
return null;
}
}