forked from 0ad/0ad
janwas
0bb0df5b2c
- remove headers always included from PCH - nommgr.h is only included ifdef REDEFINED_NEW (allows leaving out the mmgr stuff) - in lib/*.cpp, moved the corresponding include file to right behind the PCH (catches headers that aren't compilable by themselves) - byte_order no longer depends on SDL - add debug_level (another means of filtering debug output; needed for thesis) - split posix stuff up into subdirs (lib/posix and sysdep/win/wposix). makes including only some of the modules (e.g. sockets, time) much easier. This was SVN commit r4728.
63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
#include "precompiled.h"
|
|
#include "wdlfcn.h"
|
|
|
|
#include "lib/path_util.h"
|
|
#include "wposix_internal.h"
|
|
|
|
|
|
static HMODULE HMODULE_from_void(void* handle)
|
|
{
|
|
return (HMODULE)handle;
|
|
}
|
|
|
|
static void* void_from_HMODULE(HMODULE hModule)
|
|
{
|
|
return (void*)hModule;
|
|
}
|
|
|
|
|
|
int dlclose(void* handle)
|
|
{
|
|
BOOL ok = FreeLibrary(HMODULE_from_void(handle));
|
|
WARN_RETURN_IF_FALSE(ok);
|
|
return 0;
|
|
}
|
|
|
|
|
|
char* dlerror(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
void* dlopen(const char* so_name, int flags)
|
|
{
|
|
if(flags & RTLD_GLOBAL)
|
|
debug_warn("dlopen: unsupported flag(s)");
|
|
|
|
// if present, strip .so extension; add .dll extension
|
|
char dll_name[MAX_PATH];
|
|
strcpy_s(dll_name, ARRAY_SIZE(dll_name)-5, so_name);
|
|
char* ext = (char*)path_extension(dll_name);
|
|
if(ext[0] == '\0') // no extension
|
|
strcat(dll_name, ".dll"); // safe
|
|
else // need to replace extension
|
|
SAFE_STRCPY(ext, "dll");
|
|
|
|
HMODULE hModule = LoadLibrary(dll_name);
|
|
if(!hModule)
|
|
debug_warn("dlopen failed");
|
|
return void_from_HMODULE(hModule);
|
|
}
|
|
|
|
|
|
void* dlsym(void* handle, const char* sym_name)
|
|
{
|
|
HMODULE hModule = HMODULE_from_void(handle);
|
|
void* sym = GetProcAddress(hModule, sym_name);
|
|
if(!sym)
|
|
debug_warn("dlsym failed");
|
|
return sym;
|
|
}
|
|
|