all: instrument library loading

This commit is contained in:
Tristan Crawford 2024-12-31 17:21:47 -05:00 committed by Emi Gutekanst
parent c56d596ea9
commit 41ddd2249f
10 changed files with 41 additions and 16 deletions

View file

@ -274,7 +274,7 @@ const LibXkbCommon = struct {
pub fn load() !LibXkbCommon {
var lib: LibXkbCommon = undefined;
lib.handle = std.DynLib.open("libxkbcommon.so.0") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libxkbcommon.so.0");
inline for (@typeInfo(LibXkbCommon).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -327,7 +327,7 @@ const LibWaylandClient = struct {
pub fn load() !LibWaylandClient {
var lib: LibWaylandClient = undefined;
lib.handle = std.DynLib.open("libwayland-client.so.0") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libwayland-client.so.0");
inline for (@typeInfo(LibWaylandClient).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);

View file

@ -439,7 +439,7 @@ const LibX11 = struct {
XFree: *const @TypeOf(c.XFree),
pub fn load() !LibX11 {
var lib: LibX11 = undefined;
lib.handle = std.DynLib.open("libX11.so.6") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libX11.so.6");
inline for (@typeInfo(LibX11).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -459,7 +459,7 @@ const LibXCursor = struct {
XcursorLibraryLoadImage: *const @TypeOf(c.XcursorLibraryLoadImage),
pub fn load() !LibXCursor {
var lib: LibXCursor = undefined;
lib.handle = std.DynLib.open("libXcursor.so.1") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libXcursor.so.1");
inline for (@typeInfo(LibXCursor).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -475,7 +475,7 @@ const LibXRR = struct {
XRRConfigCurrentRate: *const @TypeOf(c.XRRConfigCurrentRate),
pub fn load() !LibXRR {
var lib: LibXRR = undefined;
lib.handle = std.DynLib.open("libXrandr.so.1") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libXrandr.so.1");
inline for (@typeInfo(LibXRR).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -506,7 +506,7 @@ const LibGL = struct {
glXSwapBuffers: *const fn (*c.Display, Drawable) callconv(.C) bool,
pub fn load() !LibGL {
var lib: LibGL = undefined;
lib.handle = std.DynLib.open("libGL.so.1") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libGL.so.1");
inline for (@typeInfo(LibGL).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -538,7 +538,7 @@ const LibXkbCommon = struct {
pub fn load() !LibXkbCommon {
var lib: LibXkbCommon = undefined;
lib.handle = std.DynLib.open("libxkbcommon.so.0") catch return error.LibraryNotFound;
lib.handle = try mach.dynLibOpen("libxkbcommon.so.0");
inline for (@typeInfo(LibXkbCommon).@"struct".fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);