more fixes

This commit is contained in:
Matthew 2025-08-15 06:47:06 +10:00
parent cd27688a83
commit b3d0609810
2 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,5 @@
#pragma attribute(push, nogc, nothrow)
#ifdef __linux__ #ifdef __linux__
# include <xcb/xcb.h> # include <xcb/xcb.h>
# include <X11/Xlib.h> # include <X11/Xlib.h>

View File

@ -23,6 +23,39 @@ const DEFAULT_ALIGNMENT = (void *).sizeof * 2;
version(linux) version(linux)
{ {
import core.sys.posix.sys.mman; import core.sys.posix.sys.mman;
import core.sys.posix.dlfcn;
struct Library
{
void* ptr;
};
struct Function
{
void* ptr;
};
Library LoadLibrary(string name)
{
Library lib = {
ptr: null,
};
lib.ptr = dlopen(name.ptr, RTLD_NOW);
return lib;
};
Function LoadFunction(Library lib, string name)
{
Function fn = {
ptr: null,
};
fn.ptr = dlsym(lib.ptr, name.ptr);
return fn;
};
void* void*
MemAlloc(u64 size) MemAlloc(u64 size)