mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added dynamic library handling.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
# else
|
||||
# include <time.h> // nanosleep
|
||||
# endif // BX_PLATFORM_NACL
|
||||
# include <dlfcn.h>
|
||||
#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__
|
||||
|
||||
Reference in New Issue
Block a user