blob: bd9efe10a40a7b35c0b77aecf5a5afbca95013d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <dlfcn.h>
#include <stdio.h>
#include <SDL2/SDL.h>
typedef void PlatformLibrary;
PlatformLibrary *platform_library_open(const char *path) {
void *handle = dlopen(path, RTLD_NOW);
if (!handle) {
printf("could not open library %s\n", path);
return 0;
}
return handle;
}
void platform_library_close(PlatformLibrary *handle) {
dlclose(handle);
}
void *platform_library_get_proc(PlatformLibrary *handle, const char *name) {
void *addr = dlsym(handle, name);
return addr;
}
|