summaryrefslogtreecommitdiffstats
path: root/gfx/vr/service/openvr/src/sharedlibtools_public.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/vr/service/openvr/src/sharedlibtools_public.cpp')
-rw-r--r--gfx/vr/service/openvr/src/sharedlibtools_public.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/gfx/vr/service/openvr/src/sharedlibtools_public.cpp b/gfx/vr/service/openvr/src/sharedlibtools_public.cpp
new file mode 100644
index 0000000000..048512a1de
--- /dev/null
+++ b/gfx/vr/service/openvr/src/sharedlibtools_public.cpp
@@ -0,0 +1,43 @@
+//========= Copyright Valve Corporation ============//
+#include "sharedlibtools_public.h"
+#include <string.h>
+
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
+#if defined(POSIX)
+#include <dlfcn.h>
+#endif
+
+SharedLibHandle SharedLib_Load( const char *pchPath )
+{
+#if defined( _WIN32)
+ return (SharedLibHandle)LoadLibraryEx( pchPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
+#elif defined(POSIX)
+ return (SharedLibHandle)dlopen(pchPath, RTLD_LOCAL|RTLD_NOW);
+#endif
+}
+
+void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName)
+{
+#if defined( _WIN32)
+ return (void*)GetProcAddress( (HMODULE)lib, pchFunctionName );
+#elif defined(POSIX)
+ return dlsym( lib, pchFunctionName );
+#endif
+}
+
+
+void SharedLib_Unload( SharedLibHandle lib )
+{
+ if ( !lib )
+ return;
+#if defined( _WIN32)
+ FreeLibrary( (HMODULE)lib );
+#elif defined(POSIX)
+ dlclose( lib );
+#endif
+}
+
+