From e88e3a3e2a77603d22f1f120c27b561dc9381e06 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 6 Jul 2013 16:11:58 -0700 Subject: [PATCH] Added dynamic library handling. --- include/bx/os.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/bx/os.h b/include/bx/os.h index 447ee94..54794ae 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -15,6 +15,7 @@ # else # include // nanosleep # endif // BX_PLATFORM_NACL +# include #endif // BX_PLATFORM_ namespace bx @@ -41,6 +42,51 @@ namespace bx #endif // BX_PLATFORM_ } + inline void* dlopen(const char* _filePath) + { +#if BX_PLATFORM_WINDOWS + return (void*)LoadLibraryA(_filePath); +#else + return ::dlopen(_filePath, RTLD_LOCAL|RTLD_LAZY); +#endif // BX_PLATFORM_ + } + + inline void dlclose(void* _handle) + { +#if BX_PLATFORM_WINDOWS + FreeLibrary( (HMODULE)_handle); +#else + ::dlclose(_lib); +#endif // BX_PLATFORM_ + } + + inline void* dlsym(void* _handle, const char* _symbol) + { +#if BX_PLATFORM_WINDOWS + return (void*)GetProcAddress( (HMODULE)_handle, _symbol); +#else + return dlsym(_handle, _symbol); +#endif // BX_PLATFORM_ + } + + inline void setenv(const char* _name, const char* _value) + { +#if BX_PLATFORM_WINDOWS + SetEnvironmentVariableA(_name, _value); +#else + setenv(_name, _value, 1); +#endif // BX_PLATFORM_ + } + + inline void unsetenv(const char* _name) + { +#if BX_PLATFORM_WINDOWS + SetEnvironmentVariableA(_name, NULL); +#else + unsetenv(_name); +#endif // BX_PLATFORM_ + } + } // namespace bx #endif // __BX_OS_H__