-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write dynamic linking platform shim for Windows
Last ditch effort to at least kind of support Windows natively. I'm not even going to try to port the networking code, because Windows doesn't even support berkeley sockets, as far as I know.
- Loading branch information
Showing
3 changed files
with
64 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifdef WINDOWS | ||
#include <libloaderapi.h> | ||
#else | ||
#include <dlfcn.h> | ||
#endif | ||
#include "dyn.h" | ||
|
||
void *dyn_load(const char *filename) { | ||
#ifdef WINDOWS | ||
return (void *)LoadLibraryA(filename); | ||
#else | ||
return dlopen(filename, RTLD_LAZY); | ||
#endif | ||
} | ||
|
||
void *dyn_sym(void *handle, const char *name) { | ||
#ifdef WINDOWS | ||
return (void *)GetProcAddress((HMODULE)handle, name); | ||
#else | ||
return dlsym(handle, name); | ||
#endif | ||
} | ||
|
||
int dyn_close(void *handle) { | ||
#ifdef WINDOWS | ||
return (int)FreeLibrary((HMODULE)handle); | ||
#else | ||
return dlclose(handle); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _DYN_H | ||
#define _DYN_H | ||
|
||
void *dyn_load(const char *filename); | ||
void *dyn_sym(void *handle, const char *name); | ||
int dyn_close(void *handle); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters